RoleRule
ConsoleMonster.Presenters
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.
Returned or exposed by 9
- Method RoleRule.Above
- Method RoleRule.AtLeast
- Method RoleRule.AtMost
- Method RoleRule.Below
- Method RoleRule.Equal
- Method RoleRule.When
- Property KeyValueItem.Rules
- Property RecordItem.Rules
- Property TableColumn.RoleRules
Accepted by parameters 8
- Method CellPresenters.Present
- Method KeyValueList.AddValue
- Method RecordView.AddField
- Method RecordView.AddField``1
- Extension method TableColumn.AddRoleRule
- Extension method TableColumn.AddRoleRules
- Method TableColumnFluent.AddRoleRule
- Method TableColumnFluent.AddRoleRules
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>
- The predicate.
- role ConsoleMonster.Styling.ThemeToken
- The role to apply.
Methods
public static RoleRule Above(double threshold, ThemeToken role) #Matches numbers greater than a threshold.
Parameters
- threshold double
- The threshold.
- role ConsoleMonster.Styling.ThemeToken
- The role.
public static RoleRule AtLeast(double threshold, ThemeToken role) #Matches numbers greater than or equal to a threshold.
Parameters
- threshold double
- The threshold.
- role ConsoleMonster.Styling.ThemeToken
- The role.
public static RoleRule AtMost(double threshold, ThemeToken role) #Matches numbers less than or equal to a threshold.
Parameters
- threshold double
- The threshold.
- role ConsoleMonster.Styling.ThemeToken
- The role.
public static RoleRule Below(double threshold, ThemeToken role) #Matches numbers less than a threshold.
Parameters
- threshold double
- The threshold.
- role ConsoleMonster.Styling.ThemeToken
- The role.
public static RoleRule Equal(object? expected, ThemeToken role) #Matches values equal to expected (text comparison, case-insensitive).
Parameters
- expected object?
- The expected value.
- role ConsoleMonster.Styling.ThemeToken
- The role.
public bool Matches(object? value, double? number) #Whether the rule matches.
Parameters
- value object?
- The raw value.
- number double?
- 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>
- The predicate over the raw value.
- role ConsoleMonster.Styling.ThemeToken
- The role.