Skip to content
ConsoleMonster
Class

RoleRule

ConsoleMonster.Presenters

Namespace
ConsoleMonster.Presenters
Assembly
ConsoleMonster
Modifiers
sealed

A conditional formatting rule: when a value matches, the cell takes a role (the first matching rule wins). Rules compare the presented number when there is one (numbers, bytes, durations in seconds, dates in days from now), so RoleRule.Below(30, ThemeToken.Warn) on a date column flags certificates expiring within 30 days. Without colour, a status role (pass, warn, fail) adds its symbol in front of the value, so the rule stays visible.

Inheritance

  • object
  • RoleRule

Usage

Explore 17 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 8

Constructors

public RoleRule(Func<object?, double?, bool> matches, ThemeToken role) #

Creates a rule from a predicate over the raw value and the presented number (when there is one).

Parameters

matches System.Func<object?, double?, bool> required
The predicate.
role ConsoleMonster.Styling.ThemeToken required
The role to apply.

Methods

public static RoleRule Above(double threshold, ThemeToken role) #

Matches numbers greater than a threshold.

Parameters

threshold double required
The threshold.
role ConsoleMonster.Styling.ThemeToken required
The role.

Returns

RoleRule The rule.
public static RoleRule AtLeast(double threshold, ThemeToken role) #

Matches numbers greater than or equal to a threshold.

Parameters

threshold double required
The threshold.
role ConsoleMonster.Styling.ThemeToken required
The role.

Returns

RoleRule The rule.
public static RoleRule AtMost(double threshold, ThemeToken role) #

Matches numbers less than or equal to a threshold.

Parameters

threshold double required
The threshold.
role ConsoleMonster.Styling.ThemeToken required
The role.

Returns

RoleRule The rule.
public static RoleRule Below(double threshold, ThemeToken role) #

Matches numbers less than a threshold.

Parameters

threshold double required
The threshold.
role ConsoleMonster.Styling.ThemeToken required
The role.

Returns

RoleRule The rule.
public static RoleRule Equal(object? expected, ThemeToken role) #

Matches values equal to expected (text comparison, case-insensitive).

Parameters

expected object? required
The expected value.
role ConsoleMonster.Styling.ThemeToken required
The role.

Returns

RoleRule The rule.
public bool Matches(object? value, double? number) #

Whether the rule matches.

Parameters

value object? required
The raw value.
number double? required
The presented number, or null.

Returns

bool True on a match.
public static RoleRule When(Func<object?, bool> predicate, ThemeToken role) #

Matches values for which predicate returns true.

Parameters

predicate System.Func<object?, bool> required
The predicate over the raw value.
role ConsoleMonster.Styling.ThemeToken required
The role.

Returns

RoleRule The rule.

Properties

public ThemeToken Role { get; } #

The role applied on a match.