PropertyTranslationCollection Class
Namespace: PTS.Modules.EntityTranslationComponent
Assembly: PTS.Modules.EntityTranslationComponent.dll
Holds entity property translations.
Syntax
public class PropertyTranslationCollection : IReadOnlyCollection<PropertyTranslation>, IEnumerable<PropertyTranslation>, IEnumerable
Implements
Constructors
PropertyTranslationCollection(LanguageCode)
Creates a new instance with optional default language as parameter.
Declaration
public PropertyTranslationCollection(LanguageCode defaultLanguage = LanguageCode.NotSet)
Parameters
Type | Name | Description |
---|---|---|
LanguageCode | defaultLanguage | Language that will be used to retrive and set property translations if not specified in calling methods. |
PropertyTranslationCollection(IEnumerable<IPropertyTranslation>, LanguageCode)
Creates a new instance filled with translations from supplied collection, with optional default language as parameter.
Declaration
public PropertyTranslationCollection(IEnumerable<IPropertyTranslation> translations, LanguageCode defaultLanguage = LanguageCode.NotSet)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<IPropertyTranslation> | translations | Translations to fill into the newly created instance. |
LanguageCode | defaultLanguage | Language that will be used to retrive and set property translations if not specified in calling methods. |
Properties
CommonLanguage
Language shared among all translations in collection. If null
, the collection holds more than one language or no transations are available.
Declaration
public LanguageCode? CommonLanguage { get; }
Property Value
Type | Description |
---|---|
System.Nullable<LanguageCode> |
Count
Gets the number of translations contained in the collection.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
DefaultLanguage
Language used to retrive and assign property translations if not specified in calling methods.
Declaration
public LanguageCode DefaultLanguage { get; set; }
Property Value
Type | Description |
---|---|
LanguageCode |
Properties
Properties currently available in collection.
Declaration
public PropertyTranslation[] Properties { get; }
Property Value
Type | Description |
---|---|
PropertyTranslation[] |
Methods
GetEnumerator()
Returns an enumerator that iterates through the translated properties in collection.
Declaration
public IEnumerator<PropertyTranslation> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<PropertyTranslation> | An enumerator that iterates through the translated properties in collection. |
Property(PropertyTranslationKey)
Retrieves translation for specified entity property in specified language if the paramater is set.
Declaration
public PropertyTranslation Property(PropertyTranslationKey property)
Parameters
Type | Name | Description |
---|---|---|
PropertyTranslationKey | property | Entity property to get the translation for. |
Returns
Type | Description |
---|---|
PropertyTranslation | Entity property translation value for given property translation key. |
Property<TEntity>(Expression<Func<TEntity, String>>, LanguageCode)
Retrieves translation for specified entity property in specified language if the paramater is set.
Declaration
public PropertyTranslation Property<TEntity>(Expression<Func<TEntity, string>> property, LanguageCode language = LanguageCode.NotSet)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TEntity, System.String>> | property | Expression identifying the entity property to get the translation for. |
LanguageCode | language | Translation language to look for, if not set, collection default or common language will be used. |
Returns
Type | Description |
---|---|
PropertyTranslation | Entity property translation value in specified language or collection default language. |
Type Parameters
Name | Description |
---|---|
TEntity | Type of entity to get the property translation for. |
SetProperty(IPropertyTranslation)
Sets the specified property translation.
Declaration
public PropertyTranslationCollection SetProperty(IPropertyTranslation translation)
Parameters
Type | Name | Description |
---|---|---|
IPropertyTranslation | translation |
Returns
Type | Description |
---|---|
PropertyTranslationCollection | The same instance of current class for chaining. |
SetProperty(PropertyTranslation)
Sets the specified property translation.
Declaration
public PropertyTranslationCollection SetProperty(PropertyTranslation translation)
Parameters
Type | Name | Description |
---|---|---|
PropertyTranslation | translation |
Returns
Type | Description |
---|---|
PropertyTranslationCollection | The same instance of current class for chaining. |
SetProperty(PropertyTranslationKey, String)
Sets the translation value for specified property.
Declaration
public PropertyTranslationCollection SetProperty(PropertyTranslationKey property, string value)
Parameters
Type | Name | Description |
---|---|---|
PropertyTranslationKey | property | Property key to set the translation for. |
System.String | value | Translated value for specified property. |
Returns
Type | Description |
---|---|
PropertyTranslationCollection | The same instance of current class for chaining. |
SetProperty<TEntity>(Expression<Func<TEntity, String>>, String, LanguageCode)
Sets the translation value for specified property in specified language if the paramater is set.
Declaration
public PropertyTranslationCollection SetProperty<TEntity>(Expression<Func<TEntity, string>> property, string value, LanguageCode language = LanguageCode.NotSet)
Parameters
Type | Name | Description |
---|---|---|
System.Linq.Expressions.Expression<System.Func<TEntity, System.String>> | property | Expression identifying the entity property to set the translation for. |
System.String | value | Translated value for specified property. |
LanguageCode | language | Translation language to set the value for, if not set, collection default language will be used. |
Returns
Type | Description |
---|---|
PropertyTranslationCollection | The same instance of current class for chaining. |
Type Parameters
Name | Description |
---|---|
TEntity | Type of entity to set the property translation for. |
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through the translated properties in collection.
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | An enumerator that iterates through the translated properties in collection. |