Class LanguageSet
A set of languages that can be serialized as a simple space-separated list of ISO language codes.
Namespace: NanoByte.Common.Collections
Assembly: NanoByte.Common.dll
Syntax
public class LanguageSet : SortedSet<CultureInfo>
Remarks
Uses Unix-style language codes with an underscore (_) separator.
Constructors
LanguageSet()
Creates a new empty language collection.
Declaration
public LanguageSet()
LanguageSet(IEnumerable<CultureInfo>)
Creates a new language collection pre-filled with a set of languages.
Declaration
public LanguageSet(IEnumerable<CultureInfo> collection)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<CultureInfo> | collection |
LanguageSet(SerializationInfo, StreamingContext)
Declaration
protected LanguageSet(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
SerializationInfo | info | |
StreamingContext | context |
LanguageSet(String)
Deserializes a space-separated list of languages codes.
Declaration
public LanguageSet(string value)
Parameters
Type | Name | Description |
---|---|---|
String | value | A space-separated list of languages codes (in the same format as used by the LANG environment variable). |
Remarks
Unknown language codes in value
are replaced with InvariantCulture rather than raising an ArgumentException.
Methods
Add(String)
Adds a language identified by a string to the collection.
Declaration
public bool Add(string langCode)
Parameters
Type | Name | Description |
---|---|---|
String | langCode | The string identifying the language to add. |
Returns
Type | Description |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
ArgumentException |
|
ContainsAny(IEnumerable<CultureInfo>, Boolean)
Determines whether this language set contains any of a set of target languages.
Declaration
public bool ContainsAny(IEnumerable<CultureInfo> targets, bool ignoreCountry = false)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<CultureInfo> | targets | The language set to match against. |
Boolean | ignoreCountry |
|
Returns
Type | Description |
---|---|
Boolean |
ToString()
Serializes the list as a space-separated list of languages codes.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |