Skip to content
ConsoleMonster
Class

CellPresenters

ConsoleMonster.Presenters

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? ForColumn(string? name, object? sample) #

The presenter every table infers for a column without one, from its name and a sample value: plain digits for an integer identifier (Id, Port...), or a status marker for status words (a State of "running"). PowerShell tables and typed C# tables (Table.For) share it, so the same data looks the same.

Parameters

name string? required
The column or member name.
sample object? required
The first non-null value.

Returns

ICellPresenter? The inferred presenter, or null.
public static ICellPresenter? ForLabel(string? label, object? value) #

The member-name and value-type presenter used by tables, also for record fields, trees and key/value lists: identifiers, byte counts, dates, durations, booleans and recognized status words.

Parameters

label string? required
The field label or member name.
value object? required
The value.

Returns

ICellPresenter? The matching presenter, or null for automatic value presentation.
ForMember 2 overloads
public static ICellPresenter? ForMember(string? name, Type? type) #

The presenter a column gets from its member name and value type, or null for the default. Same as CellPresenters.ForMember without a source type, so a bare Length or Size stays a number.

Parameters

name string? required
The member or column name.
type System.Type? required
The value type, or null when unknown.

Returns

ICellPresenter? The presenter, or null.
public static ICellPresenter? ForMember(string? name, Type? type, Type? sourceType) #

The presenter a column gets from its member name, value type and the type of the object it was read from, or null for the default: plain digits for integer identifiers (Id, PID, Port, Index, Year, names ending in Id or Port), dates for DateTime and DateTimeOffset, durations for TimeSpan, Yes/No for booleans, status markers for enums whose names read as a status (Running, Stopped, Failed...), and byte counts for integer members whose name means bytes: names ending in Bytes, Memory, WorkingSet, WorkingSet64, MemorySize64 or FileSize (SizeInBytes, PrivateMemorySize64, PeakWorkingSet64...), and SizeOnDisk; exactly Length or Size, only when is file-like (), as for a . Other names ending in Length or Size (MinLength, MaxLength, BatchSize, PageSize) are counts and stay numbers.

Parameters

name string? required
The member or column name.
type System.Type? required
The value type, or null when unknown.
sourceType System.Type? required
The type of the object the value was read from, or null when unknown.

Returns

ICellPresenter? The presenter, or null.
public static ICellPresenter? ForStatus(string? name, object? sample) #

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 string? required
The column or member name.
sample object? required
A sample value.

Returns

ICellPresenter? The status presenter, or null.
public static ICellPresenter FromName(string name, string? unit = null) #

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

Parameters

name string required
The name.
unit string? = null optional
The unit for Number, or null.

Returns

ICellPresenter The presenter.

Exceptions

  • ArgumentException – The name is unknown.
public static bool IsFileSource(Type? sourceType) #

Whether values read from objects of this type use a bare Length or Size for a byte count: files, directories and streams (FileSystemInfo, Stream).

Parameters

sourceType System.Type? required
The type of the object, or null.

Returns

bool True for file-like types.
public static PresentedValue Present(object? value, ICellPresenter? presenter, IReadOnlyList<RoleRule>? rules, PresenterContext context) #

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 object? required
The raw value.
presenter ConsoleMonster.Presenters.ICellPresenter? required
The presenter, or null for automatic.
rules System.Collections.Generic.IReadOnlyList<ConsoleMonster.Presenters.RoleRule>? required
Tone rules, or null.
context ConsoleMonster.Presenters.PresenterContext required
The presenter context.

Returns

PresentedValue 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 BytesBar { get; } #

Byte sizes with a data bar scaled to the column's largest size (see DataBarPresenter).

public static ICellPresenter DurationBar { get; } #

Durations with a data bar scaled to the column's longest duration (see DataBarPresenter).

public static ICellPresenter Sparkline { get; } #

Series as sparklines.

public static ICellPresenter Progress { get; } #

Fractions and done/total as progress.

public static ICellPresenter Chip { get; } #

Literal category text in a bracketed chip.

public static ICellPresenter MemberSignature { get; } #

PowerShell member signatures with muted types and highlighted member names.

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.