Class LocalizedTextSet
An immutable set of localized strings for one achievement field, keyed by locale code (for
example "en", "es-AR").
Implements
Inherited Members
Namespace: Serenity.Achievements.Application.Sync
Assembly: Serenity.Achievements.Application.dll
Syntax
public sealed class LocalizedTextSet : IEquatable<LocalizedTextSet>
Remarks
A storefront lists an achievement's display name and description per locale, and a pull snapshot has to carry every locale it read back without picking a "current" one — the planner that later diffs push against pull needs the whole set to know which locales matched and which did not. Enumeration is ordinal-sorted by locale code so two sets built from the same content in a different order compare and print identically.
Properties
Count
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int | How many locales this set carries. |
Empty
A set with no locales at all.
Declaration
public static LocalizedTextSet Empty { get; }
Property Value
| Type | Description |
|---|---|
| LocalizedTextSet |
LocaleCodes
Declaration
public IReadOnlyList<string> LocaleCodes { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<string> | Every locale code this set carries, ordinal-sorted. |
Methods
Equals(LocalizedTextSet)
Declaration
public bool Equals(LocalizedTextSet other)
Parameters
| Type | Name | Description |
|---|---|---|
| LocalizedTextSet | other |
Returns
| Type | Description |
|---|---|
| bool |
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
FromDictionary(IReadOnlyDictionary<string, string>)
Builds a set from an existing locale-code-to-text map.
Declaration
public static LocalizedTextSet FromDictionary(IReadOnlyDictionary<string, string> textsByLocaleCode)
Parameters
| Type | Name | Description |
|---|---|---|
| IReadOnlyDictionary<string, string> | textsByLocaleCode | The texts to copy in, keyed by locale code. |
Returns
| Type | Description |
|---|---|
| LocalizedTextSet | A new immutable set holding a copy of the given entries. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | When no map was given. |
| ArgumentException | When any locale code is null or whitespace. |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
TryGet(string, out string)
Reads the text for one locale.
Declaration
public bool TryGet(string localeCode, out string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | localeCode | The locale code to look up. |
| string | text | The text for that locale, or empty when it is not present. |
Returns
| Type | Description |
|---|---|
| bool | Whether the locale is present in this set. |
With(string, string)
Returns a copy of this set with one locale's text added or replaced.
Declaration
public LocalizedTextSet With(string localeCode, string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | localeCode | The locale code to set. |
| string | text | The text for that locale. |
Returns
| Type | Description |
|---|---|
| LocalizedTextSet | The resulting set. This instance is unchanged. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | When the locale code is null or whitespace. |