Class MultilingualString
Represents a string that may defined in multiple languages.
Inheritance
Namespace: Algenta.Colectica.Model.Utility
Assembly: Algenta.Colectica.Model.dll
Syntax
public class MultilingualString : Dictionary<string, string>, INotifyPropertyChanged
Constructors
MultilingualString()
Initializes a new instance of the MultilingualString class.
Declaration
public MultilingualString()
MultilingualString(String)
Initializes a new instance of the MultilingualString class.
Declaration
public MultilingualString(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | A value to be assigned for the current culture. |
MultilingualString(String, String)
Initializes a new instance of the MultilingualString class.
Declaration
public MultilingualString(string value, string culture)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | A value to be assigned for the specified culture. |
System.String | culture | The culture to which the specified value should be applied. |
Properties
Best
Gets the best string, according to the SortOrder
.
Declaration
public string Best { get; }
Property Value
Type | Description |
---|---|
System.String | The best. |
BestCulture
Gets the best culture, according to the SortOrder
.
Declaration
public string BestCulture { get; }
Property Value
Type | Description |
---|---|
System.String | The best culture. |
BestPlainText
Gets the best string, according to the SortOrder
, in plain text.
Declaration
public string BestPlainText { get; }
Property Value
Type | Description |
---|---|
System.String | The best plain text. |
Current
Gets or sets the value for the culture specified by CurrentCulture.
Declaration
public string Current { get; set; }
Property Value
Type | Description |
---|---|
System.String | The value for the culture specified by CurrentCulture. |
CurrentCulture
Gets or sets the current default culture, which can be accessed with the Current
property.
Declaration
public static string CurrentCulture { get; set; }
Property Value
Type | Description |
---|---|
System.String |
CurrentLanguageDefaultAudience
Gets or sets the value for the current culture and the default (unnamed) audience.
Declaration
public string CurrentLanguageDefaultAudience { get; set; }
Property Value
Type | Description |
---|---|
System.String |
CurrentPlainText
Gets or sets the current plain text.
Declaration
public string CurrentPlainText { get; set; }
Property Value
Type | Description |
---|---|
System.String | The current plain text. |
HasMultipleAudiences
Gets a value indicating whether the string has content for multiple audiences.
Declaration
public bool HasMultipleAudiences { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
HasValue
Gets a value indicating whether this instance contains any strings for any cultures.
Declaration
public bool HasValue { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsEmpty
Gets a value indicating whether this instance contains any strings for any cultures.
Declaration
public bool IsEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Item[String]
Gets or sets the value associated with the specified language.
Declaration
public string this[string key] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key. |
Property Value
Type | Description |
---|---|
System.String |
KeysWithValues
Gets the collection of language identifiers with values.
Declaration
public Collection<string> KeysWithValues { get; }
Property Value
Type | Description |
---|---|
Collection<System.String> |
KeysWithValuesInAnyAudience
Gets a collection of languages where the default audience has a value or any other audiences have a value for the language.
Declaration
public Collection<string> KeysWithValuesInAnyAudience { get; }
Property Value
Type | Description |
---|---|
Collection<System.String> |
PropertyEventsSuspended
Gets a value indicating whether property events are suspended.
Declaration
public bool PropertyEventsSuspended { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
SupportsFormatting
Gets or sets a value indicating whether the string supports formatting.
Declaration
public bool SupportsFormatting { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Methods
AppendTo(String, String)
Appends the specified value to the specified culture.
Declaration
public void AppendTo(string culture, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | culture | The culture. |
System.String | value | The value. |
AppendTo(String, String, String)
Appends the specified value to the specified culture using the specified separator.
Declaration
public void AppendTo(string culture, string value, string seperator)
Parameters
Type | Name | Description |
---|---|---|
System.String | culture | The culture. |
System.String | value | The value. |
System.String | seperator | The seperator. |
Copy(MultilingualString)
Copies the values from the specified source into this instance. Replaces any existing information in this instance.
Declaration
public void Copy(MultilingualString source)
Parameters
Type | Name | Description |
---|---|---|
MultilingualString | source | The source. |
FromString31Serialization(String)
Builds the MultilingualString
from a DDI 3.1 XML representation.
Declaration
public void FromString31Serialization(string serialization)
Parameters
Type | Name | Description |
---|---|---|
System.String | serialization | The DDI 3 XML serialization. |
FromString31Serialization(XElement)
Populates this instance from a DDI 3.1 XML representation.
Declaration
public void FromString31Serialization(XElement root)
Parameters
Type | Name | Description |
---|---|---|
XElement | root | The root. |
GetAudiences()
Gets all audiences for which content is defined.
Declaration
public string[] GetAudiences()
Returns
Type | Description |
---|---|
System.String[] |
GetPlainText(String)
Converts the specified string to plain text, removing any HTML formatting.
Declaration
public static string GetPlainText(string str)
Parameters
Type | Name | Description |
---|---|---|
System.String | str | The string. |
Returns
Type | Description |
---|---|
System.String |
GetPlainTextForLanguage(String)
Gets the plain text for the specified language.
Declaration
public string GetPlainTextForLanguage(string lang)
Parameters
Type | Name | Description |
---|---|---|
System.String | lang | The language. |
Returns
Type | Description |
---|---|
System.String |
GetString(String)
Gets the string for the specified culture and the default audience.
Declaration
public string GetString(string culture)
Parameters
Type | Name | Description |
---|---|---|
System.String | culture | The culture. |
Returns
Type | Description |
---|---|
System.String |
GetString(String, String, Boolean)
Gets the string for the specified language and audience.
Declaration
public string GetString(string culture, string audience, bool useFirstAudienceIgnoringAudienceName = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | culture | The culture. |
System.String | audience | The audience. |
System.Boolean | useFirstAudienceIgnoringAudienceName | if set to |
Returns
Type | Description |
---|---|
System.String |
GetStringsForAudience(String)
Gets a dictionary (language -> content) for the specified audience.
Declaration
public Dictionary<string, string> GetStringsForAudience(string audience)
Parameters
Type | Name | Description |
---|---|---|
System.String | audience |
Returns
Type | Description |
---|---|
Dictionary<System.String, System.String> |
Merge(MultilingualString, Boolean)
Merges the values in the specified source with this instance. If this instance already contains
a value for a culture, the values may be joined with
Declaration
public void Merge(MultilingualString source, bool append = false)
Parameters
Type | Name | Description |
---|---|---|
MultilingualString | source | The source. |
System.Boolean | append | if set to |
OnPropertyChanged(String)
Raises the PropertyChanged event.
Declaration
public void OnPropertyChanged(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | Name of the property. |
RemoveAudience(String)
Removes the text for the specified audience.
Declaration
public bool RemoveAudience(string audience)
Parameters
Type | Name | Description |
---|---|---|
System.String | audience |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if text for the audience was removed; otherwise false. |
ResumePropertyEvents()
Resumes issuing property events.
Declaration
public void ResumePropertyEvents()
SetString(String, String, String)
Sets the string for the specified language and the specified audience.
Declaration
public void SetString(string culture, string audience, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | culture | The language. |
System.String | audience | The audience. |
System.String | value | The text. |
SetStringForDefaultAudience(String, String)
Sets the string for specified language and the default audience.
Declaration
public void SetStringForDefaultAudience(string culture, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | culture | The culture. |
System.String | value | The value. |
SuspendPropertyEvents()
Suspends issuing property events.
Declaration
public void SuspendPropertyEvents()
ToString31Serialization()
Returns a string containing a DDI 3 XML representation of the MultilingualString
.
Declaration
public string ToString31Serialization()
Returns
Type | Description |
---|---|
System.String | The DDI 3 XML serialization |
ToXElement31Serialization()
Converts the string to it's DDI 3.1 XML representation.
Declaration
public XElement ToXElement31Serialization()
Returns
Type | Description |
---|---|
XElement |
Events
CurrentCultureChanged
Occurs when the current culture is changed.
Declaration
public static event EventHandler CurrentCultureChanged
Event Type
Type | Description |
---|---|
EventHandler |
PropertyChanged
Occurs when a property value changes.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type | Description |
---|---|
PropertyChangedEventHandler |