Class ValueDisplayFormatter
Renders a raw numeric value as invariant-culture display text according to a ValueDisplaySpec. Pure formatting with no engine dependencies, so it can be unit tested outside an editor/player context and shared by every module that puts a number on screen (HUD elements, leaderboard rows, results screens).
Inherited Members
Namespace: Serenity.Shared.Utils
Assembly: Serenity.Shared.dll
Syntax
public static class ValueDisplayFormatter
Methods
Format(double, ValueDisplayFormat)
Formats value with a format's defaults (no padding, no grouping).
Declaration
public static string Format(double value, ValueDisplayFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The raw value to render. |
| ValueDisplayFormat | format | The format family to render with. |
Returns
| Type | Description |
|---|---|
| string | The formatted, invariant-culture display text. |
Format(double, ValueDisplaySpec)
Formats value according to spec. Non-finite input
(NaN/Infinity) is treated as zero, so the result is always that format's zero
representation (e.g. "0", "0.00", "0:00") rather than a malformed string.
Declaration
public static string Format(double value, ValueDisplaySpec spec)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The raw value to render (a duration in seconds for the time formats). |
| ValueDisplaySpec | spec | How to render it. |
Returns
| Type | Description |
|---|---|
| string | The formatted, invariant-culture display text. |