Table of Contents

Class TranslationCollection<T>

Namespace
Dynamicweb.Ecommerce.International
Assembly
Dynamicweb.Ecommerce.dll

Represents a collection of translations.

[Serializable]
public class TranslationCollection<T> : ICollection<T>, IEnumerable<T>, IEnumerable where T : Translation

Type Parameters

T

The type of the translations in the collection.

Inheritance
TranslationCollection<T>
Implements
Inherited Members
Extension Methods

Constructors

TranslationCollection(Func<string, T>)

Initializes a new instance of the TranslationCollection<T> class which is empty.

public TranslationCollection(Func<string, T> translationFactory)

Parameters

translationFactory Func<string, T>

Factory method which is used to create new instances of T given a language identifier.

Properties

Count

Gets the number of elements contained in the TranslationCollection<T>.

public int Count { get; }

Property Value

int

IsReadOnly

Gets a value indicating whether the TranslationCollection<T> is read-only.

public bool IsReadOnly { get; }

Property Value

bool

LanguageIds

Gets a collection containing the language identifiers.

public ICollection<string> LanguageIds { get; }

Property Value

ICollection<string>

Methods

Add(T)

Adds a translation to the the TranslationCollection<T>.

public void Add(T item)

Parameters

item T

The translation to add.

Clear()

Removes all translations from the TranslationCollection<T>.

public void Clear()

Contains(string)

Determines whether the TranslationCollection<T> contains a translation with the specified language identifier.

public bool Contains(string languageId)

Parameters

languageId string

Language identifier.

Returns

bool

true if TranslationCollection<T> contains a translation for the language identifier; otherwise, false.

Contains(T)

Determines whether the TranslationCollection<T> contains the specified translation.

public bool Contains(T item)

Parameters

item T

The translation to locate in the TranslationCollection<T>.

Returns

bool

true if item is found in the TranslationCollection<T>; otherwise, false.

CopyTo(T[], int)

Copies the elements of the TranslationCollection<T> to an Array, starting at a particular Array index.

public void CopyTo(T[] array, int arrayIndex)

Parameters

array T[]

The one-dimensional Array that is the destination of the elements copied from TranslationCollection<T>. The Array must have zero-based indexing.

arrayIndex int

The zero-based index in array at which copying begins.

Get(string)

Gets the translation for the specified language.

public T Get(string languageId)

Parameters

languageId string

Language identifier.

Returns

T

A translation instance if the specified language was found; othwerwise, null.

Get(string, params string[])

Gets the translation for the given language or any fallback language.

public T Get(string languageId, params string[] fallbackLanguageIds)

Parameters

languageId string

Language identifier.

fallbackLanguageIds string[]

Fallback language identifiers.

Returns

T

A translation instance if any of the specified languages was found; othwerwise, null.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

An IEnumerator<T> object that can be used to iterate through the collection.

GetOrAdd(string)

Gets or adds the translation for the specified language.

public T GetOrAdd(string languageId)

Parameters

languageId string

Language identifier.

Returns

T

A translation instance if the specified language or fallback language was found; othwerwise, null.

Remove(string)

Removes the element with the specified language identifier from the TranslationCollection<T>.

public bool Remove(string languageId)

Parameters

languageId string

Language identifier.

Returns

bool

true if the translation is successfully removed; otherwise, false. This method also returns false if a translation for the language was not found.

Remove(T)

Removes the element from the collection.

public bool Remove(T item)

Parameters

item T

The element to remove.

Returns

bool

true if the element is successfully removed; otherwise, false. This method also returns false if the element was not found.

Set(T)

Sets a translation and replaces any existing translation for the same language.

public void Set(T item)

Parameters

item T

The translation to set.

To top