Class AchievementConditionPhrasing
Formatting knowledge shared by more than one condition node's Describe(bool) override: how a quantity prints, how an optional name reads when nothing was authored, how a signal type's short name is derived, how a composite brackets itself once nested, and how a composite joins its children into one line.
Inherited Members
Namespace: Serenity.Achievements.Application.Conditions
Assembly: Serenity.Achievements.Application.dll
Syntax
public static class AchievementConditionPhrasing
Remarks
Each node still owns its own sentence — "Signal X ×5", "Score k ≥ 10" — but the
pieces three or more of them assemble that sentence from are one behaviour with one reason to
change, not copies across the ten condition files that would drift the moment one of them is
edited. AchievementConditionSummary owns the recursion policy this helper's
JoinChildren(IReadOnlyList<AchievementCondition>, string, string) leans on; this class owns no policy of its own about what a tree
means, only how its pieces print.
Methods
JoinChildren(IReadOnlyList<AchievementCondition>, string, string)
Joins a composite's children into one line, separated by separator, or
reports emptySummary when it has none.
Declaration
public static string JoinChildren(IReadOnlyList<AchievementCondition> children, string separator, string emptySummary)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyList<AchievementCondition> | children | The children to join, in order. |
| string | separator | What sits between two consecutive children. |
| string | emptySummary | What to report when there are no children at all. |
Returns
| Type | Description |
|---|---|
| string |
NameOrPlaceholder(string)
An authored name, or a placeholder when it was left blank.
Declaration
public static string NameOrPlaceholder(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The authored name, which may be null, empty or whitespace. |
Returns
| Type | Description |
|---|---|
| string |
Parenthesize(string, bool)
Wraps a composite's summary in brackets when it sits inside another one, so
"A AND (B OR C)" cannot be read as "A AND B OR C".
Declaration
public static string Parenthesize(string summary, bool isNested)
Parameters
| Type | Name | Description |
|---|---|---|
| string | summary | The already-composed summary to wrap. |
| bool | isNested | Whether the summary sits inside another node's summary. |
Returns
| Type | Description |
|---|---|
| string |
Quantity(float)
Formats a float the way an authored quantity reads: trimmed, invariant.
Declaration
public static string Quantity(float value)
Parameters
| Type | Name | Description |
|---|---|---|
| float | value | The value to format. |
Returns
| Type | Description |
|---|---|
| string |
ShortTypeName(string)
The bare type name of an authored signal, which is what an author recognizes.
Declaration
public static string ShortTypeName(string typeName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | typeName | The signal type name, in any of the forms authoring may store. |
Returns
| Type | Description |
|---|---|
| string |