NanoByte.Common  2.9.0
NanoByte.Common.Collections.LocalizableStringCollection Class Reference

A collection of LocalizableStrings with language-search methods. More...

Inheritance diagram for NanoByte.Common.Collections.LocalizableStringCollection:
NanoByte.Common.ICloneable< LocalizableStringCollection >

Public Member Functions

void Add ([Localizable(false)] string language, string? value)
 Adds a new string with an associated language to the collection. More...
 
void Add (string value)
 Adds a new en string to the collection. More...
 
bool ContainsExactLanguage (CultureInfo language)
 Checks if the collection contains an entry exactly matching the specified language. More...
 
string? GetExactLanguage (CultureInfo language)
 Returns the first string in the collection exactly matching the specified language. More...
 
string? GetBestLanguage (CultureInfo language)
 Returns the best-fitting string in the collection for the specified language. More...
 
void Set (CultureInfo language, string? value)
 Adds a new string with an associated language to the collection. Preexisting entries with the same language are removed. More...
 
LocalizableStringCollection Clone ()
 Creates a deep copy of this LocalizableStringCollection (elements are cloned). More...
 
- Public Member Functions inherited from NanoByte.Common.ICloneable< LocalizableStringCollection >
Clone ()
 Creates a new clone of this instance. More...
 

Detailed Description

A collection of LocalizableStrings with language-search methods.

Member Function Documentation

◆ Add() [1/2]

void NanoByte.Common.Collections.LocalizableStringCollection.Add ( [Localizable(false)] string  language,
string?  value 
)
inline

Adds a new string with an associated language to the collection.

Parameters
languageThe language of the value .
valueThe actual string value to store.

◆ Add() [2/2]

void NanoByte.Common.Collections.LocalizableStringCollection.Add ( string  value)

Adds a new en string to the collection.

Parameters
valueThe actual string value to store.

◆ Clone()

LocalizableStringCollection NanoByte.Common.Collections.LocalizableStringCollection.Clone ( )
inline

Creates a deep copy of this LocalizableStringCollection (elements are cloned).

Returns
The cloned LocalizableStringCollection.

◆ ContainsExactLanguage()

bool NanoByte.Common.Collections.LocalizableStringCollection.ContainsExactLanguage ( CultureInfo  language)
inline

Checks if the collection contains an entry exactly matching the specified language.

Parameters
languageThe exact language to look for.
Returns
true if an element with the specified language exists in the collection; false otherwise.
See also
GetExactLanguage

◆ GetBestLanguage()

string? NanoByte.Common.Collections.LocalizableStringCollection.GetBestLanguage ( CultureInfo  language)
inline

Returns the best-fitting string in the collection for the specified language.

Parameters
languageThe language to look for.
Returns
The best-fitting string value found in the collection; null if the collection is empty.

Language preferences in decreasing order:

  1. exact match
  2. same language with neutral culture
  3. en
  4. en-US
  5. first entry in collection

◆ GetExactLanguage()

string? NanoByte.Common.Collections.LocalizableStringCollection.GetExactLanguage ( CultureInfo  language)
inline

Returns the first string in the collection exactly matching the specified language.

Parameters
languageThe exact language to look for.
Returns
The string value found in the collection; null if none was found.
See also
ContainsExactLanguage

◆ Set()

void NanoByte.Common.Collections.LocalizableStringCollection.Set ( CultureInfo  language,
string?  value 
)
inline

Adds a new string with an associated language to the collection. Preexisting entries with the same language are removed.

Parameters
languageThe language of the value .
valueThe actual string value to store; null to remove existing entries.

The documentation for this class was generated from the following file: