NanoByte.Common  2.8.1
NanoByte.Common.Collections.LanguageSet Class Reference

A set of languages that can be serialized as a simple space-separated list of ISO language codes. More...

Inheritance diagram for NanoByte.Common.Collections.LanguageSet:

Public Member Functions

 LanguageSet ()
 Creates a new empty language collection. More...
 
 LanguageSet ([InstantHandle] IEnumerable< CultureInfo > collection)
 Creates a new language collection pre-filled with a set of languages. More...
 
 LanguageSet (string value)
 Deserializes a space-separated list of languages codes. More...
 
bool Add (string langCode)
 Adds a language identified by a string to the collection. More...
 
bool ContainsAny ([InstantHandle] IEnumerable< CultureInfo > targets, bool ignoreCountry=false)
 Determines whether this language set contains any of a set of target languages. More...
 
override string ToString ()
 Serializes the list as a space-separated list of languages codes. More...
 

Protected Member Functions

 LanguageSet (SerializationInfo info, StreamingContext context)
 

Detailed Description

A set of languages that can be serialized as a simple space-separated list of ISO language codes.

Uses Unix-style language codes with an underscore (_) separator.

Constructor & Destructor Documentation

◆ LanguageSet() [1/3]

NanoByte.Common.Collections.LanguageSet.LanguageSet ( )
inline

Creates a new empty language collection.

◆ LanguageSet() [2/3]

NanoByte.Common.Collections.LanguageSet.LanguageSet ( [InstantHandle] IEnumerable< CultureInfo >  collection)
inline

Creates a new language collection pre-filled with a set of languages.

Parameters
collection

◆ LanguageSet() [3/3]

NanoByte.Common.Collections.LanguageSet.LanguageSet ( string  value)
inline

Deserializes a space-separated list of languages codes.

Parameters
valueA space-separated list of languages codes (in the same format as used by the LANG environment variable).

Unknown language codes in value are replaced with CultureInfo.InvariantCulture rather than raising an ArgumentException.

Member Function Documentation

◆ Add()

bool NanoByte.Common.Collections.LanguageSet.Add ( string  langCode)

Adds a language identified by a string to the collection.

Parameters
langCodeThe string identifying the language to add.
Returns
true if the language could be added, false otherwise.
Exceptions
ArgumentExceptionlangCode is not a valid language code.

◆ ContainsAny()

bool NanoByte.Common.Collections.LanguageSet.ContainsAny ( [InstantHandle] IEnumerable< CultureInfo >  targets,
bool  ignoreCountry = false 
)
inline

Determines whether this language set contains any of a set of target languages.

Parameters
targetsThe language set to match against.
ignoreCountrytrue to compare only the two-letter language name; false to also compare the country code.

◆ ToString()

override string NanoByte.Common.Collections.LanguageSet.ToString ( )
inline

Serializes the list as a space-separated list of languages codes.


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