Class LocalizableStringCollection
- Namespace
- NanoByte.Common.Collections
- Assembly
- NanoByte.Common.dll
A collection of LocalizableStrings with language-search methods.
[Serializable]
public class LocalizableStringCollection : List<LocalizableString>, ICloneable<LocalizableStringCollection>
- Inheritance
-
objectList<LocalizableString>LocalizableStringCollection
- Implements
- Extension Methods
Methods
Add(string)
Adds a new en string to the collection.
public void Add(string value)
Parameters
valuestringThe actual string value to store.
Add(string, string?)
Adds a new string with an associated language to the collection.
public void Add(string language, string? value)
Parameters
languagestringThe language of the
value.valuestringThe actual string value to store.
Clone()
Creates a deep copy of this LocalizableStringCollection (elements are cloned).
public LocalizableStringCollection Clone()
Returns
ContainsExactLanguage(CultureInfo)
Checks if the collection contains an entry exactly matching the specified language.
public bool ContainsExactLanguage(CultureInfo language)
Parameters
languageCultureInfoThe exact language to look for.
Returns
- bool
trueif an element with the specified language exists in the collection;falseotherwise.
- See Also
GetBestLanguage(CultureInfo)
Returns the best-fitting string in the collection for the specified language.
public string? GetBestLanguage(CultureInfo language)
Parameters
languageCultureInfoThe language to look for.
Returns
- string
The best-fitting string value found in the collection;
nullif the collection is empty.
Remarks
Language preferences in decreasing order:
- exact match
- same language with neutral culture
- en
- en-US
- first entry in collection
GetExactLanguage(CultureInfo)
Returns the first string in the collection exactly matching the specified language.
public string? GetExactLanguage(CultureInfo language)
Parameters
languageCultureInfoThe exact language to look for.
Returns
- string
The string value found in the collection;
nullif none was found.
- See Also
Set(CultureInfo, string?)
Adds a new string with an associated language to the collection. Preexisting entries with the same language are removed.
public void Set(CultureInfo language, string? value)
Parameters
languageCultureInfoThe language of the
value.valuestringThe actual string value to store;
nullto remove existing entries.