Class LocalizableValue<T>
Template for localized values of different types that provides methods for working with them.
Implements
Inherited Members
Namespace: Terrasoft.Common
Assembly: Terrasoft.Common.dll
Syntax
public abstract class LocalizableValue<T> : LocalizableValue, ICloneable where T : class
Type Parameters
Name | Description |
---|---|
T | Localized values of the System.String, System.Drawing.Image type. |
Constructors
LocalizableValue()
Initializes a new instance of the LocalizableValue class.
Declaration
protected LocalizableValue()
LocalizableValue(T)
Initializes a new instance of the LocalizableValue class with the specified value of specific type.
Declaration
protected LocalizableValue(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | Value for initialization. |
LocalizableValue(String, String)
Initializes a new instance of the LocalizableValue class using the specified resource manager and specified resource element.
Declaration
protected LocalizableValue(string resourceManagerName, string resourceItemName)
Parameters
Type | Name | Description |
---|---|---|
System.String | resourceManagerName | Resource manager. |
System.String | resourceItemName | Resource item. |
LocalizableValue(IResourceStorage, String, String)
Initializes a new instance of the LocalizableValue class using the specified resource storage, resource manager and resource item.
Declaration
protected LocalizableValue(IResourceStorage storage, string resourceManagerName, string resourceItemName)
Parameters
Type | Name | Description |
---|---|---|
IResourceStorage | storage | A resource storage. |
System.String | resourceManagerName | Resource manager. |
System.String | resourceItemName | Resource item. |
LocalizableValue(LocalizableValue<T>)
Initializes a new LocalizableValue instance using set localized value of specific type.
Declaration
protected LocalizableValue(LocalizableValue<T> source)
Parameters
Type | Name | Description |
---|---|---|
LocalizableValue<T> | source | Localized value of set type. |
Remarks
The constructor creates a new object, which is a copy of source
.
Properties
CultureValues
Gets a lookup of localized values of the current instance for supported cultures.
Declaration
public IDictionary<CultureInfo, T> CultureValues { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.Globalization.CultureInfo, T> |
HasValue
Determines whether a localized value of the current type exists for the current culture.
Declaration
public bool HasValue { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Value
Gets and sets localized value taking the current culture into account.
Declaration
public virtual T Value { get; set; }
Property Value
Type | Description |
---|---|
T |
Methods
ClearCultureValue(CultureInfo)
Clears the localized value for the specified culture.
Declaration
public void ClearCultureValue(CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | Culture. |
GetCultureValue(CultureInfo, Boolean)
Gets the localized value of the specified type for the specified culture.
Depending on the value of the throwIfNoManager
parameter method may generate an exception
of type ItemNotFoundException, unless a resource manager is set for this localized value.
Declaration
public T GetCultureValue(CultureInfo culture, bool throwIfNoManager)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | Culture. |
System.Boolean | throwIfNoManager | Flag that indicates if method has to throw exception ItemNotFoundException. |
Returns
Type | Description |
---|---|
T | Localized value of specified type. |
Exceptions
Type | Condition |
---|---|
ItemNotFoundException | If |
GetCultureValueWithFallback(CultureInfo, Boolean)
Gets the localized value of the specified type for the specified culture. If value for the specified culture
is not found, default culture value is returned.
Depending on the value of the throwIfNoManager
parameter method may generate an exception
of type ItemNotFoundException, unless a resource manager is set for this localized value.
Declaration
public T GetCultureValueWithFallback(CultureInfo culture, bool throwIfNoManager)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | Culture. |
System.Boolean | throwIfNoManager | Flag that indicates if method has to throw exception ItemNotFoundException. |
Returns
Type | Description |
---|---|
T | Localized value of specified type. |
Exceptions
Type | Condition |
---|---|
ItemNotFoundException | If |
GetFromResourceManager(CultureInfo, String)
Gets localized value of the set type by resource name and culture.
Declaration
protected abstract T GetFromResourceManager(CultureInfo culture, string itemName)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | Culture. |
System.String | itemName | Name of the resource item. |
Returns
Type | Description |
---|---|
T |
GetFromResourceManagerWithCultureFallback(CultureInfo, String)
Declaration
protected abstract T GetFromResourceManagerWithCultureFallback(CultureInfo culture, string itemName)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | |
System.String | itemName |
Returns
Type | Description |
---|---|
T |
HasAnyValue()
Declaration
protected virtual bool HasAnyValue()
Returns
Type | Description |
---|---|
System.Boolean |
HasCultureValue(CultureInfo)
Determines whether a localized value exists for the specified culture.
Declaration
public override bool HasCultureValue(CultureInfo culture)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | Culture. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Overrides
LoadCultureValues()
Loads a list of localized values of the specified type for all cultures set in the global resource storage.
Declaration
public override void LoadCultureValues()
Overrides
ResetCultureValues()
Resets values of the culture for the current localized value.
Declaration
protected override void ResetCultureValues()
Overrides
SetCultureValue(CultureInfo, T)
Sets the specified localized value for the specified culture.
Declaration
public virtual void SetCultureValue(CultureInfo culture, T value)
Parameters
Type | Name | Description |
---|---|---|
System.Globalization.CultureInfo | culture | Culture. |
T | value | Localized value. |