Skip to content
ConsoleMonster
Class

NumberPresenter

ConsoleMonster.Presenters

Namespace
ConsoleMonster.Presenters
Assembly
ConsoleMonster
Implements
ICellPresenter
Modifiers
sealed

A number, right-aligned, with the culture's thousand and decimal separators and an optional unit: 12,480, 8.4 rules/s, 97.5 %. Non-numeric values are shown as text.

Inheritance

  • object
  • NumberPresenter

Constructors

public NumberPresenter(string? unit = null, int? decimals = null) #

Creates a number presenter.

Parameters

unit string? = null optional
A unit appended after a space (muted), or null.
decimals int? = null optional
Fixed decimals, or null for automatic: in a table column the most decimals any of its numbers needs (at most two), elsewhere up to two (none for whole numbers).

Methods

public PresentedValue Present(object? value, PresenterContext context) #

Presents a value.

Parameters

value object? required
The raw value (may be null).
context ConsoleMonster.Presenters.PresenterContext required
Culture, clock, time zone, column statistics and the render context.

Returns

PresentedValue The presented value.

Properties

public string? Unit { get; } #

The unit, or null.

public int? Decimals { get; } #

Fixed decimals, or null for automatic.

public ThemeToken? ZeroRole { get; set; } #

An optional semantic role for a zero value.

public ThemeToken? NonZeroRole { get; set; } #

An optional semantic role for a nonzero value.