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
-
LocalizableStringCollection
- Implements
- Extension Methods
Methods
Add(string)
Adds a new en
string to the collection.
public void Add(string value)
Parameters
value
stringThe 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
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
language
CultureInfoThe exact language to look for.
Returns
- bool
true
if an element with the specified language exists in the collection;false
otherwise.
- See Also
GetBestLanguage(CultureInfo)
Returns the best-fitting string in the collection for the specified language.
public string? GetBestLanguage(CultureInfo language)
Parameters
language
CultureInfoThe language to look for.
Returns
- string
The best-fitting string value found in the collection;
null
if 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
language
CultureInfoThe exact language to look for.
Returns
- string
The string value found in the collection;
null
if 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
language
CultureInfoThe language of the
value
.value
stringThe actual string value to store;
null
to remove existing entries.