Show / Hide Table of Contents

Class LanguageSet

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

Inheritance
Object
LanguageSet
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

true if the language could be added, false otherwise.

Exceptions
Type Condition
ArgumentException

langCode is not a valid language code.

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

true to compare only the two-letter language name; false to also compare the country code.

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

Extension Methods

UpdateUtils.To<TIn, TOut>(TIn, Func<TIn, TOut>)
JsonStorage.SaveJson<T>(T, Stream)
JsonStorage.SaveJson<T>(T, String)
JsonStorage.ToJsonString<T>(T)
JsonStorage.ReparseAsJson<T>(Object)
JsonStorage.ReparseAsJson<T>(Object, T)
XmlStorage.SaveXml(Object, Stream, String)
XmlStorage.SaveXml<T>(T, String, String)
XmlStorage.ToXmlString(Object, String)
ConversionUtils.ConvertToString<TType>(TType)
In This Article
Back to top Copyright Bastian Eicher