Class MultilingualString
Represents a string that may defined in multiple languages.
Implements
Inherited Members
Namespace: Algenta.Colectica.Model.Utility
Assembly: Algenta.Colectica.Model.dll
Syntax
public class MultilingualString : Dictionary<string, string>, IDictionary<string, string>, ICollection<KeyValuePair<string, string>>, IDictionary, ICollection, IReadOnlyDictionary<string, string>, IReadOnlyCollection<KeyValuePair<string, string>>, IEnumerable<KeyValuePair<string, string>>, IEnumerable, ISerializable, IDeserializationCallback, 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 |
|---|---|---|
| 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 |
|---|---|---|
| string | value | A value to be assigned for the specified culture. |
| string | culture | The culture to which the specified value should be applied. |
Properties
AsyncLocalCurrentCulture
Gets or sets the current ambient culture that is local to a given asynchronous control flow
Declaration
public static string AsyncLocalCurrentCulture { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
AudienceStrings
Gets or sets the audience strings.
Declaration
public Dictionary<string, Dictionary<string, string>> AudienceStrings { get; set; }
Property Value
| Type | Description |
|---|---|
| Dictionary<string, Dictionary<string, string>> |
Best
Gets the best string, according to the SortOrder.
Declaration
public string Best { get; }
Property Value
| Type | Description |
|---|---|
| string | The best. |
BestCulture
Gets the best culture, according to the SortOrder.
Declaration
public string BestCulture { get; }
Property Value
| Type | Description |
|---|---|
| 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 |
|---|---|
| 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 |
|---|---|
| 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 |
|---|---|
| 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 |
|---|---|
| string |
CurrentPlainText
Gets or sets the current plain text.
Declaration
public string CurrentPlainText { get; set; }
Property Value
| Type | Description |
|---|---|
| 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 |
|---|---|
| bool |
|
HasValue
Gets a value indicating whether this instance contains any strings for any cultures.
Declaration
public bool HasValue { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
IsEmpty
Gets a value indicating whether this instance contains any strings for any cultures.
Declaration
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
this[string]
Gets or sets the value associated with the specified language.
Declaration
[SuppressPropertyChangedWarnings]
public string this[string key] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The key. |
Property Value
| Type | Description |
|---|---|
| string |
KeysWithValues
Gets the collection of language identifiers with values.
Declaration
public Collection<string> KeysWithValues { get; }
Property Value
| Type | Description |
|---|---|
| Collection<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<string> |
PropertyEventsSuspended
Gets a value indicating whether property events are suspended.
Declaration
public bool PropertyEventsSuspended { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
SupportsFormatting
Gets or sets a value indicating whether the string supports formatting.
Declaration
public bool SupportsFormatting { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Methods
AppendTo(string, string)
Appends the specified value to the specified culture.
Declaration
public void AppendTo(string culture, string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture | The culture. |
| 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 |
|---|---|---|
| string | culture | The culture. |
| string | value | The value. |
| string | seperator | The seperator. |
ClearAll()
Clear the multilingual string and all audence strings
Declaration
public void ClearAll()
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. |
Equals(object)
Determines whether the full content of two multilingual strings is equal.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Overrides
FromString31Serialization(string)
Builds the MultilingualString from a DDI 3.1 XML representation.
Declaration
public void FromString31Serialization(string serialization)
Parameters
| Type | Name | Description |
|---|---|---|
| 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 |
|---|---|
| string[] |
GetHashCode()
Get the Hash Code
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Overrides
GetPlainText(string)
Converts the specified string to plain text, removing any HTML formatting.
Declaration
public static string GetPlainText(string str)
Parameters
| Type | Name | Description |
|---|---|---|
| string | str | The string. |
Returns
| Type | Description |
|---|---|
| string |
GetPlainTextForLanguage(string)
Gets the plain text for the specified language.
Declaration
public string GetPlainTextForLanguage(string lang)
Parameters
| Type | Name | Description |
|---|---|---|
| string | lang | The language. |
Returns
| Type | Description |
|---|---|
| string |
GetString(string)
Gets the string for the specified culture and the default audience.
Declaration
public string GetString(string culture)
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture | The culture. |
Returns
| Type | Description |
|---|---|
| string |
GetString(string, string, bool)
Gets the string for the specified language and audience.
Declaration
public string GetString(string culture, string audience, bool useFirstAudienceIgnoringAudienceName = false)
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture | The culture. |
| string | audience | The audience. |
| bool | useFirstAudienceIgnoringAudienceName | if set to |
Returns
| Type | Description |
|---|---|
| string |
GetStringsForAudience(string)
Gets a dictionary (language -> content) for the specified audience.
Declaration
public Dictionary<string, string> GetStringsForAudience(string audience)
Parameters
| Type | Name | Description |
|---|---|---|
| string | audience |
Returns
| Type | Description |
|---|---|
| Dictionary<string, string> |
Merge(MultilingualString, bool)
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 NewLine.
Declaration
public void Merge(MultilingualString source, bool append = false)
Parameters
| Type | Name | Description |
|---|---|---|
| MultilingualString | source | The source. |
| bool | append | if set to |
OnPropertyChanged(string)
Raises the PropertyChanged event.
Declaration
public void OnPropertyChanged(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| 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 |
|---|---|---|
| string | audience |
Returns
| Type | Description |
|---|---|
| bool | 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 |
|---|---|---|
| string | culture | The language. |
| string | audience | The audience. |
| 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 |
|---|---|---|
| string | culture | The culture. |
| 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 |
|---|---|
| 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 |