Skip to content
ConsoleMonster
Class

PresenterContext

ConsoleMonster.Presenters

Namespace
ConsoleMonster.Presenters
Assembly
ConsoleMonster
Modifiers
sealed

Everything a presenter may depend on, so output is deterministic for a given culture, clock and terminal.

Inheritance

  • object
  • PresenterContext

Usage

Explore 25 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 22

Constructors

public PresenterContext(RenderContext render, CultureInfo? culture = null, DateTimeOffset? now = null, TimeZoneInfo? timeZone = null) #

Creates a presenter context.

Parameters

render ConsoleMonster.Canvas.RenderContext required
The render context (profile, theme, glyphs).
culture System.Globalization.CultureInfo? = null optional
The culture for numbers and dates, or null for the render culture (RenderContext.Culture).
now System.DateTimeOffset? = null optional
The reference time for relative dates, or null for the current time.
timeZone System.TimeZoneInfo? = null optional
The time zone for absolute dates, or null for local time.

Methods

public static int DecimalsNeeded(object? value) #

The decimals a number needs once rounded to two: 0 for whole numbers, 1 for 11.7, 2 for 3.14159 (numeric text such as "1.5" counts by its digits). Integer types, and numbers too large to carry fractions, need none.

Parameters

value object? required
The raw value.

Returns

int 0, 1 or 2; 0 for non-numbers.
public PresenterContext WithColumn(double? maximum, int? decimals) #

Returns a copy with column statistics: the largest value and the decimals the column's numbers share.

Parameters

maximum double? required
The maximum, or null.
decimals int? required
The shared decimals, or null.

Returns

PresenterContext The copy.
public PresenterContext WithColumnMaximum(double? maximum) #

Returns a copy with a column maximum.

Parameters

maximum double? required
The maximum.

Returns

PresenterContext The copy.

Properties

public RenderContext Render { get; } #

The render context.

public CultureInfo Culture { get; } #

The culture for numbers (thousand separators, decimals) and dates.

public DateTimeOffset Now { get; } #

The reference time for relative dates.

public TimeZoneInfo TimeZone { get; } #

The time zone absolute dates are shown in.

public double? ColumnMaximum { get; set; } #

The largest numeric value in the column (data bars scale to it), or null.

public int? ColumnDecimals { get; set; } #

The decimals every number in the column is shown with (the most any of its values needs, at most two), so the decimal separators line up; null outside a column, where each number shows up to two decimals of its own.

public bool HasColor { get; } #

Whether the output can carry colour; without it, tones are expressed with symbols and words.