Skip to content
ConsoleMonster

API Reference

Class

CellPresenters

Namespace ConsoleMonster.Presenters
Assembly ConsoleMonster
Modifiers static

The built-in presenters by name, and the shared presentation step (presenter, then tone rules) used by tables, record cards, record views, key/value lists and trees.

Inheritance

  • Object
  • CellPresenters

Methods

public static ICellPresenter? ForLabel(String? label, Object? value) #
Returns: ICellPresenter?

The identifier presenter for an integer whose label reads as an identifier (Id, ProcessId, Port, Handle...), so record fields, trees and key/value lists show 8080 and 127096 as tables do, never 8 080.

Parameters

label System.String? requiredposition: 0
The field label or member name.
value System.Object? requiredposition: 1
The value.

Returns

The identifier presenter, or null.

public static ICellPresenter? ForMember(String? name, Type? type) #
Returns: ICellPresenter?

The presenter a column gets from its member name and value type, or null for the default: plain digits for integer identifiers (Id, PID, Port, Index, Year, names ending in Id or Port), byte counts for integer members named Size, Length, Bytes, WorkingSet or Memory (and names ending in them), dates for DateTime and DateTimeOffset, durations for TimeSpan, Yes/No for booleans, and status markers for enums whose names read as a status (Running, Stopped, Failed...).

Parameters

name System.String? requiredposition: 0
The member or column name.
type System.Type? requiredposition: 1
The value type, or null when unknown.

Returns

The presenter, or null.

public static ICellPresenter? ForStatus(String? name, Object? sample) #
Returns: ICellPresenter?

The status presenter for a column whose values read as statuses, whatever presenters are otherwise chosen: an enum with status names (ServiceControllerStatus), or text in a column named like a status (Status, State, Result, Outcome, Health, Level, Severity) whose value is a status word (Success, Warning, Error, Running...). The value's own word is kept, with a marker and tone: ✓ Success, ▴ Warning.

Parameters

name System.String? requiredposition: 0
The column or member name.
sample System.Object? requiredposition: 1
A sample value.

Returns

The status presenter, or null.

public static ICellPresenter FromName(String name, String? unit = null) #
Returns: ICellPresenter

Returns a built-in presenter by name (case-insensitive): Text, Auto, Status, Number, Bytes, Duration, Date, DateRelative, DateBoth, Boolean, Bar (DataBar), Sparkline, Progress, Link.

Parameters

name System.String requiredposition: 0
The name.
unit System.String? = null optionalposition: 1
The unit for Number, or null.

Returns

The presenter.

Exceptions

  • ArgumentException – The name is unknown.
public static PresentedValue Present(Object? value, ICellPresenter? presenter, IReadOnlyList<ToneRule>? rules, PresenterContext context) #
Returns: PresentedValue

Presents a value with a presenter (or CellPresenters.Auto) and applies the first matching tone rule: the text takes the rule's colour, and without colour a status tone adds its symbol in front.

Parameters

value System.Object? requiredposition: 0
The raw value.
presenter ConsoleMonster.Presenters.ICellPresenter? requiredposition: 1
The presenter, or null for automatic.
rules System.Collections.Generic.IReadOnlyList<ConsoleMonster.Presenters.ToneRule>? requiredposition: 2
Tone rules, or null.
context ConsoleMonster.Presenters.PresenterContext requiredposition: 3
The presenter context.

Returns

The presented value.

Properties

public static ICellPresenter Text { get; } #

Plain text.

public static ICellPresenter Emoji { get; } #

Text with :shortcode: emoji, degraded per glyph tier (see EmojiPresenter).

public static ICellPresenter Identifier { get; } #

Identifier numbers (ids, ports, indexes, years) without thousands separators (see IdentifierPresenter).

public static ICellPresenter StatusWord { get; } #

Enum or text values that read as a status, shown with a marker (see StatusEnumPresenter).

public static ICellPresenter Auto { get; } #

Chooses by value type.

public static ICellPresenter Status { get; } #

Status symbol, word and tone.

public static ICellPresenter Number { get; } #

Numbers with culture separators, right-aligned.

public static ICellPresenter Bytes { get; } #

Byte counts in binary units.

public static ICellPresenter Duration { get; } #

Durations (TimeSpan, or numbers in seconds).

public static ICellPresenter Date { get; } #

Absolute dates.

public static ICellPresenter Boolean { get; } #

Booleans as symbol and word.

public static ICellPresenter DataBar { get; } #

Numbers with a data bar.

public static ICellPresenter Sparkline { get; } #

Series as sparklines.

public static ICellPresenter Progress { get; } #

Fractions and done/total as progress.

public static ICellPresenter Markup { get; } #

Text values interpreted as markup ([pass]OK[/]); invalid markup is shown literally. Data stays literal unless a column opts in with this presenter.