CellPresenters
ConsoleMonster.Presenters
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?
- The column or member name.
- sample object?
- The first non-null value.
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?
- The field label or member name.
- value object?
- The value.
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?
- The member or column name.
- type System.Type?
- The value type, or null when unknown.
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?
- The member or column name.
- type System.Type?
- The value type, or null when unknown.
- sourceType System.Type?
- The type of the object the value was read from, or null when unknown.
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?
- The column or member name.
- sample object?
- A sample value.
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
- The name.
- unit string? = null
- The unit for Number, or null.
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?
- 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?
- The raw value.
- presenter ConsoleMonster.Presenters.ICellPresenter?
- The presenter, or null for automatic.
- rules System.Collections.Generic.IReadOnlyList<ConsoleMonster.Presenters.RoleRule>?
- Tone rules, or null.
- context ConsoleMonster.Presenters.PresenterContext
- The presenter context.
Inherited Methods
Properties
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 Number { get; } #Numbers with culture separators, right-aligned.
public static ICellPresenter Duration { get; } #Durations (TimeSpan, or numbers in seconds).
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 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.