Class LeaderboardValueFormatter
Renders a raw leaderboard entry value as invariant-culture display text according to a LeaderboardValueFormat.
Inherited Members
Namespace: Serenity.Leaderboard.Infrastructure.Views
Assembly: Serenity.UnityLeaderboard.Infrastructure.dll
Syntax
public static class LeaderboardValueFormatter
Remarks
The formatting itself lives in ValueDisplayFormatter (Shared), which the HUD and any other number-rendering module share. This type stays as the leaderboard's own vocabulary — a small set of presets — mapping each preset onto the general spec. The spec has never had a precision ceiling; Decimal is what lets an author reach it.
Fields
DefaultDecimalPlaces
Decimal places applied to Decimal when no authored precision
travels with the format. Callers that hold a definition should pass its DecimalPlaces instead.
Declaration
public const int DefaultDecimalPlaces = 2
Field Value
| Type | Description |
|---|---|
| int |
Methods
Format(double, LeaderboardValueFormat)
Formats value according to format. 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, LeaderboardValueFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The raw value to render (a duration in seconds for the time formats). |
| LeaderboardValueFormat | format | Which display format to apply. |
Returns
| Type | Description |
|---|---|
| string | The formatted, invariant-culture display text. |
Format(double, LeaderboardValueFormat, int)
Formats value according to format, using
decimalPlaces when the format is Decimal.
Declaration
public static string Format(double value, LeaderboardValueFormat format, int decimalPlaces)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The raw value to render (a duration in seconds for the time formats). |
| LeaderboardValueFormat | format | Which display format to apply. |
| int | decimalPlaces | Authored precision; ignored by every format except |
Returns
| Type | Description |
|---|---|
| string | The formatted, invariant-culture display text. |
ToSpec(LeaderboardValueFormat)
Maps a leaderboard preset onto the general display spec that renders it.
Declaration
public static ValueDisplaySpec ToSpec(LeaderboardValueFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| LeaderboardValueFormat | format | The leaderboard preset. |
Returns
| Type | Description |
|---|---|
| ValueDisplaySpec | The equivalent display spec. |
ToSpec(LeaderboardValueFormat, int)
Maps a leaderboard preset onto the general display spec that renders it, honouring
decimalPlaces for Decimal.
Declaration
public static ValueDisplaySpec ToSpec(LeaderboardValueFormat format, int decimalPlaces)
Parameters
| Type | Name | Description |
|---|---|---|
| LeaderboardValueFormat | format | The leaderboard preset. |
| int | decimalPlaces | Authored precision; ignored by every format except |
Returns
| Type | Description |
|---|---|
| ValueDisplaySpec | The equivalent display spec. Precision is clamped by the spec itself. |