Show / Hide Table of Contents

Class ResourceManager

The ResourceManager is a singleton object which controls access to all resources.

Inheritance
object
ResourceManager
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.Globalization
Assembly: SoCore.dll
Syntax
public class ResourceManager
Examples

Use like this:

string someText = ResourceManager.GetString("symbolname");

The ResourceManager will return the value associated with "symbolname" according to the current UI culture.

Constructors

ResourceManager()

The ResourceManager is a singleton object which controls access to all resources.

Declaration
public ResourceManager()
Examples

Use like this:

string someText = ResourceManager.GetString("symbolname");

The ResourceManager will return the value associated with "symbolname" according to the current UI culture.

See Also
IResourceProvider

Fields

DEFAULT_CULTURE

Ultimate fallback culture

Declaration
public const string DEFAULT_CULTURE = "en-US"
Field Value
Type Description
string
See Also
IResourceProvider

Properties

CultureInfo

Gets the CultureInfo used by the ResourceManager. The set accessor will call SetCulture(string) with the name of the culture, setting it on the current thread. CultureInfo is used for formatting dates, number etc. See UICultureInfo for translating resource.

Declaration
public static CultureInfo CultureInfo { get; }
Property Value
Type Description
CultureInfo
See Also
IResourceProvider

StartupCulture

The culture that was in effect when the ResourceManager was first touched. This may be important as it reflects the Control Panel settings. You can have a French Windows, running the Windows client in German, and it says "Italian - Switzerland" in Control Panel. In that case we would like to remember the control panel setting somewhere, but at the same time we need to overwrite it

Declaration
public static CultureInfo StartupCulture { get; set; }
Property Value
Type Description
CultureInfo
See Also
IResourceProvider

UICultureInfo

Gets the CultureInfo used by the ResourceManager. The set accessor will call SetCulture(string) with the name of the culture, setting it on the current thread. UICultureInfo is used for translating resources. CultureInfo for formatting dates, numbers, etc.

Declaration
public static CultureInfo UICultureInfo { get; }
Property Value
Type Description
CultureInfo
See Also
IResourceProvider

Methods

ConvertDayOfWeekToLocalizedString(DayOfWeek)

Returns a DayOfWeek enum to a localized string.

Declaration
public static string ConvertDayOfWeekToLocalizedString(DayOfWeek dayOfWeek)
Parameters
Type Name Description
DayOfWeek dayOfWeek

The day of week to convert.

Returns
Type Description
string

A localized string containing the localized day of week string.

See Also
IResourceProvider

ConvertToLongDateString(DateTime)

Converts a date to a localized long date string using the culture of the ResourceManager

Declaration
public static string ConvertToLongDateString(DateTime date)
Parameters
Type Name Description
DateTime date

DateTime to convert

Returns
Type Description
string

A localized long date string

See Also
IResourceProvider

ConvertToShortDateString(DateTime)

Converts a date to a localized short date string using the culture of the ResourceManager

Declaration
public static string ConvertToShortDateString(DateTime date)
Parameters
Type Name Description
DateTime date

DateTime to convert

Returns
Type Description
string

A localized short date string

See Also
IResourceProvider

ConvertToShortTimeString(DateTime)

Converts a time to a localized short time string using the current culture

Declaration
public static string ConvertToShortTimeString(DateTime time)
Parameters
Type Name Description
DateTime time
Returns
Type Description
string
See Also
IResourceProvider

FilterForClient(string, ClientFilterFormat)

The ResourceManager is a singleton object which controls access to all resources.

Declaration
public static string FilterForClient(string resString, ClientFilterFormat clientformat)
Parameters
Type Name Description
string resString
ClientFilterFormat clientformat
Returns
Type Description
string
Examples

Use like this:

string someText = ResourceManager.GetString("symbolname");

The ResourceManager will return the value associated with "symbolname" according to the current UI culture.

See Also
IResourceProvider

FindResourceStrings(string, string)

Returns all resource strings containing searchString in the specified culture

Declaration
public static string[] FindResourceStrings(string searchString, string cultureName)
Parameters
Type Name Description
string searchString

The string to search for, in both the resource name and the resource value. Case insensitive

string cultureName

The name of the culture in the form en-US, nb-NO

Returns
Type Description
string[]

Array of resource names matching searchString

See Also
IResourceProvider

GetAbbreviatedDayOfWeekToLocalizedString(DayOfWeek)

Returns a DayOfWeek enum to a abbreviated localized string.

Declaration
public static string GetAbbreviatedDayOfWeekToLocalizedString(DayOfWeek dayOfWeek)
Parameters
Type Name Description
DayOfWeek dayOfWeek

The day of week to convert.

Returns
Type Description
string

localized string containing the abbreviated localized day of week string.

See Also
IResourceProvider

GetAllTranslatedResourceStrings(string)

The ResourceManager is a singleton object which controls access to all resources.

Declaration
public static string[] GetAllTranslatedResourceStrings(string cultureName)
Parameters
Type Name Description
string cultureName
Returns
Type Description
string[]
Examples

Use like this:

string someText = ResourceManager.GetString("symbolname");

The ResourceManager will return the value associated with "symbolname" according to the current UI culture.

See Also
IResourceProvider

GetCulture()

Returns the name of the current culture. Equivalent to ResourceManager.CultureInfo.Name

Declaration
public static string GetCulture()
Returns
Type Description
string

"nb-NO" or "en-US" or similar.

See Also
IResourceProvider

GetCultureCodeFromSOLangCode(string)

The ResourceManager is a singleton object which controls access to all resources.

Declaration
public static string GetCultureCodeFromSOLangCode(string langCode)
Parameters
Type Name Description
string langCode
Returns
Type Description
string
Examples

Use like this:

string someText = ResourceManager.GetString("symbolname");

The ResourceManager will return the value associated with "symbolname" according to the current UI culture.

See Also
IResourceProvider

GetEnumResourceName(Enum)

Gets a resource label string associated with an enum value

Declaration
public static string GetEnumResourceName(Enum enumValue)
Parameters
Type Name Description
Enum enumValue

The enum value

Returns
Type Description
string

The resource label string associated with an enum value.

See Also
IResourceProvider

GetInlineLabelString(string)

Gets a resource string in the current culture, and represents it as an inline label string

Declaration
public static string GetInlineLabelString(string resourceName)
Parameters
Type Name Description
string resourceName

The resource/symbol name.

Returns
Type Description
string

The string that the symbol represents.

See Also
IResourceProvider

GetMonthToAbbreviatedLocalizedString(int)

Returns a month into a abbreviated localized string.

Declaration
public static string GetMonthToAbbreviatedLocalizedString(int month)
Parameters
Type Name Description
int month

The month to return.

Returns
Type Description
string

Localized abbreviated month name.

See Also
IResourceProvider

GetMonthToLocalizedString(int)

Returns a month into a localized string.

Declaration
public static string GetMonthToLocalizedString(int month)
Parameters
Type Name Description
int month

The month to return.

Returns
Type Description
string

Localized month name.

See Also
IResourceProvider

GetMultiLangString(string, IEnumerable<string>, string, bool, ClientFilterFormat)

The ResourceManager is a singleton object which controls access to all resources.

Declaration
public static string GetMultiLangString(string resourceName, IEnumerable<string> languages, string defaultLanguageISO, bool ignoreUserDefinedFieldLabels = false, ClientFilterFormat filterFormat = ClientFilterFormat.Web)
Parameters
Type Name Description
string resourceName
IEnumerable<string> languages
string defaultLanguageISO
bool ignoreUserDefinedFieldLabels
ClientFilterFormat filterFormat
Returns
Type Description
string
Examples

Use like this:

string someText = ResourceManager.GetString("symbolname");

The ResourceManager will return the value associated with "symbolname" according to the current UI culture.

See Also
IResourceProvider

GetProviderInfo()

The ResourceManager is a singleton object which controls access to all resources.

Declaration
public static ResourceManager.ProviderInfo[] GetProviderInfo()
Returns
Type Description
ProviderInfo[]
Examples

Use like this:

string someText = ResourceManager.GetString("symbolname");

The ResourceManager will return the value associated with "symbolname" according to the current UI culture.

See Also
IResourceProvider

GetSOLangCodeFromCultureInfo(CultureInfo)

The ResourceManager is a singleton object which controls access to all resources.

Declaration
public static string GetSOLangCodeFromCultureInfo(CultureInfo culture)
Parameters
Type Name Description
CultureInfo culture
Returns
Type Description
string
Examples

Use like this:

string someText = ResourceManager.GetString("symbolname");

The ResourceManager will return the value associated with "symbolname" according to the current UI culture.

See Also
IResourceProvider

GetString(Enum, ResourceStringFormat, bool, ClientFilterFormat)

Gets a resource string in the current culture.

Declaration
public static string GetString(Enum enumValue, ResourceStringFormat format, bool ignoreUserDefinedFieldLabels = false, ClientFilterFormat filterFormat = ClientFilterFormat.Web)
Parameters
Type Name Description
Enum enumValue

The enum value

ResourceStringFormat format

Determines how the string should be formatted

bool ignoreUserDefinedFieldLabels

Ignore user defined field labels

ClientFilterFormat filterFormat

Apply any known client specific filtering, default: Web

Returns
Type Description
string

The string that the symbol represents.

See Also
IResourceProvider

GetString(Enum, bool, ClientFilterFormat)

Gets a resource string in the current culture.

Declaration
public static string GetString(Enum enumValue, bool ignoreUserDefinedFieldLabels = false, ClientFilterFormat filterFormat = ClientFilterFormat.Web)
Parameters
Type Name Description
Enum enumValue

The enum value

bool ignoreUserDefinedFieldLabels

Ignore user defined field labels

ClientFilterFormat filterFormat

Apply any known client specific filtering, default: Web

Returns
Type Description
string

The string that the symbol represents.

See Also
IResourceProvider

GetString(Enum, string, bool, ClientFilterFormat)

Gets a string in a specific culture.

Declaration
public static string GetString(Enum enumValue, string cultureName, bool ignoreUserDefinedFieldLabels = false, ClientFilterFormat filterFormat = ClientFilterFormat.Web)
Parameters
Type Name Description
Enum enumValue

The enum value

string cultureName

The culture, e.g. "nb-NO"

bool ignoreUserDefinedFieldLabels

Ignore user defined field labels

ClientFilterFormat filterFormat

Apply any known client specific filtering, default: Web

Returns
Type Description
string

The string that the symbol represents.

See Also
IResourceProvider

GetString(string, ResourceStringFormat, bool, ClientFilterFormat, bool)

Gets a resource string in the current culture. Colons and shortcut indicators can be stripped/manipulated.

Declaration
public static string GetString(string resourceName, ResourceStringFormat format, bool ignoreUserDefinedFieldLabels = false, ClientFilterFormat filterFormat = ClientFilterFormat.Web, bool simpleResourceTranslation = false)
Parameters
Type Name Description
string resourceName

The resource/symbol name.

ResourceStringFormat format

Determines how the string should be formatted

bool ignoreUserDefinedFieldLabels

Ignore user defined field labels

ClientFilterFormat filterFormat

Apply any known client specific filtering, default: Web

bool simpleResourceTranslation
Returns
Type Description
string

The string that the symbol represents.

See Also
IResourceProvider

GetString(string, bool, ClientFilterFormat)

Gets a resource string in the current culture.

Declaration
public static string GetString(string resourceName, bool ignoreUserDefinedFieldLabels = false, ClientFilterFormat filterFormat = ClientFilterFormat.Web)
Parameters
Type Name Description
string resourceName

The resource/symbol name.

bool ignoreUserDefinedFieldLabels

Ignore user defined field labels

ClientFilterFormat filterFormat

Apply any known client specific filtering, default: Web

Returns
Type Description
string

The string that the symbol represents.

See Also
IResourceProvider

GetString(string, string, bool, ClientFilterFormat, bool)

Gets a string in a specific culture.

Declaration
public static string GetString(string resourceName, string culturename, bool ignoreUserDefinedFieldLabels = false, ClientFilterFormat filterFormat = ClientFilterFormat.Web, bool simpleResourceTranslation = false)
Parameters
Type Name Description
string resourceName

The resource/symbol name.

string culturename
bool ignoreUserDefinedFieldLabels

Ignore user defined field labels

ClientFilterFormat filterFormat

Apply any known client specific filtering, default: Web

bool simpleResourceTranslation
Returns
Type Description
string

The string that the symbol represents.

See Also
IResourceProvider

GetSupportedLanguages()

The ResourceManager is a singleton object which controls access to all resources.

Declaration
public static CultureInfo[] GetSupportedLanguages()
Returns
Type Description
CultureInfo[]
Examples

Use like this:

string someText = ResourceManager.GetString("symbolname");

The ResourceManager will return the value associated with "symbolname" according to the current UI culture.

See Also
IResourceProvider

GetUICulture()

The ResourceManager is a singleton object which controls access to all resources.

Declaration
public static string GetUICulture()
Returns
Type Description
string
Examples

Use like this:

string someText = ResourceManager.GetString("symbolname");

The ResourceManager will return the value associated with "symbolname" according to the current UI culture.

See Also
IResourceProvider

GetUnfilteredResourceForCulture(string, string)

Returns the unfiltered string from this provider in the specified culture

Declaration
public static string GetUnfilteredResourceForCulture(string name, string cultureName)
Parameters
Type Name Description
string name

The name of the resource/resource symbol

string cultureName

The name of the culture in the form en-US, nb-NO

Returns
Type Description
string

The unfiltered resource string, or null if not found

See Also
IResourceProvider

GetUnfilteredResourcesForCulture(string)

Returns all resource strings for the specified culture as a dictionary

Declaration
public static Dictionary<string, string> GetUnfilteredResourcesForCulture(string cultureName)
Parameters
Type Name Description
string cultureName

The name of the culture in the form en-US, nb-NO

Returns
Type Description
Dictionary<string, string>

Dictionary of all resource labels and values

See Also
IResourceProvider

ParseInlineResources(string)

Parses a resource string with inline resources of the format "text [symbol] more text [next symbol] ... Replaces the symbols with actual text

Declaration
public static string ParseInlineResources(string resourceString)
Parameters
Type Name Description
string resourceString

The resource string to parse

Returns
Type Description
string

Parsed resource string.

See Also
IResourceProvider

ParseInlineResources(string, bool)

Parses a resource string with inline resources of the format "text [symbol] more text [next symbol] ... Replaces the symbols with actual text. Also uses the CultureDataFormatter to parse and reformat any culture-sensitive data in the text, for instance dates... provided they have been encoded using the CultureDataFormatter in the first place.

Declaration
public static string ParseInlineResources(string resourceString, bool suppressColons)
Parameters
Type Name Description
string resourceString

The resource string to parse

bool suppressColons
Returns
Type Description
string

Parsed resource string.

See Also
IResourceProvider

ParseInlineResources(string, string)

Parses a resource string with inline resources of the format "text [symbol] more text [next symbol] ... Replaces the symbols with actual text. Also uses the CultureDataFormatter to parse and reformat any culture-sensitive data in the text, for instance dates... provided they have been encoded using the CultureDataFormatter in the first place.

Declaration
public static string ParseInlineResources(string resourceString, string cultureName)
Parameters
Type Name Description
string resourceString

The resource string to parse

string cultureName

The cultureName, typically en-US, nb-NO, but also US, NO is accepted

Returns
Type Description
string

Parsed resource string.

See Also
IResourceProvider

ParseInlineResources(string, string, bool)

Parses a resource string with inline resources of the format "text [symbol] more text [next symbol] ... Replaces the symbols with actual text. Also uses the CultureDataFormatter to parse and reformat any culture-sensitive data in the text, for instance dates... provided they have been encoded using the CultureDataFormatter in the first place.

Declaration
public static string ParseInlineResources(string resourceString, string cultureName, bool suppressColons)
Parameters
Type Name Description
string resourceString

The resource string to parse

string cultureName

The cultureName, typically en-US, nb-NO, but also US, NO is accepted

bool suppressColons

Should colons be supressed

Returns
Type Description
string

Parsed resource string.

Remarks

In the string 'this [ is maybe [SR_SINGULAR_CONTACT] a resource [] Apple ][ would like', the SR_SINGULAR_CONTACT is a valid resource, everything else is not, and will be left alone by the parser.

See Also
IResourceProvider

ParseInlineResources(string, string, bool, ClientFilterFormat)

Parses a resource string with inline resources of the format "text [symbol] more text [next symbol] ... Replaces the symbols with actual text. Also uses the CultureDataFormatter to parse and reformat any culture-sensitive data in the text, for instance dates... provided they have been encoded using the CultureDataFormatter in the first place.

Declaration
public static string ParseInlineResources(string resourceString, string cultureName, bool suppressColons, ClientFilterFormat filterFormat = ClientFilterFormat.Web)
Parameters
Type Name Description
string resourceString

The resource string to parse

string cultureName

The cultureName, typically en-US, nb-NO, but also US, NO is accepted

bool suppressColons

Should colons be supressed

ClientFilterFormat filterFormat

Apply any known client specific filtering, default: Web

Returns
Type Description
string

Parsed resource string.

Remarks

In the string 'this [ is maybe [SR_SINGULAR_CONTACT] a resource [] Apple ][ would like', the SR_SINGULAR_CONTACT is a valid resource, everything else is not, and will be left alone by the parser.

See Also
IResourceProvider

ParseInlineResources(string, string, bool, ClientFilterFormat, bool, bool, bool)

Parses a resource string with inline resources of the format "text [symbol] more text [next symbol] ... Replaces the symbols with actual text. Also uses the CultureDataFormatter to parse and reformat any culture-sensitive data in the text, for instance dates... provided they have been encoded using the CultureDataFormatter in the first place.

Declaration
public static string ParseInlineResources(string resourceString, string cultureName, bool suppressColons, ClientFilterFormat filterFormat = ClientFilterFormat.Web, bool skipMultiLanguageStrings = false, bool skipLocalizeEncodedValues = false, bool simpleResourceTranslation = false)
Parameters
Type Name Description
string resourceString

The resource string to parse

string cultureName

The cultureName, typically en-US, nb-NO, but also US, NO is accepted

bool suppressColons

Should colons be supressed

ClientFilterFormat filterFormat

Apply any known client specific filtering, default: Web

bool skipMultiLanguageStrings
bool skipLocalizeEncodedValues
bool simpleResourceTranslation
Returns
Type Description
string

Parsed resource string.

Remarks

In the string 'this [ is maybe [SR_SINGULAR_CONTACT] a resource [] Apple ][ would like', the SR_SINGULAR_CONTACT is a valid resource, everything else is not, and will be left alone by the parser.

See Also
IResourceProvider

ParseMultiLanguageString(string)

Returns the string part of the default culture from the multi language string These strings are typically used in SuperOffice list and description data String example from PrefDesc table: US:"Location and size";US:"Location and size";GE:"Position und Größe";NO:"Posisjon og størrelse"

Declaration
public static string ParseMultiLanguageString(string multilangString)
Parameters
Type Name Description
string multilangString

The multilanguage string to parse

Returns
Type Description
string

Default culture specific string part

See Also
IResourceProvider

ParseMultiLanguageString(string, string)

Returns the string part of the specified culture from the multi language string These strings are typically used in SuperOffice list and description data String example from PrefDesc table: US:"Location and size";GE:"Position und Größe";NO:"Posisjon og størrelse"

Declaration
public static string ParseMultiLanguageString(string multilangString, string cultureName)
Parameters
Type Name Description
string multilangString

The multilanguage string to parse

string cultureName

The cultureName, typically en-US, nb-NO, but also US, NO is accepted

Returns
Type Description
string

Culture specific string part

See Also
IResourceProvider

Refresh()

Refresh all resource providers.

Declaration
public static void Refresh()
See Also
IResourceProvider

SetCulture(string)

Sets the culture of the currently executing thread.

Declaration
public static void SetCulture(string culturename)
Parameters
Type Name Description
string culturename
See Also
IResourceProvider

SetCulture(string, string)

Sets the culture of the currently executing thread. Specific cultures are respected, neutral cultures are converted into the default specific variant.

Declaration
public static void SetCulture(string cultureName, string cultureUiName)
Parameters
Type Name Description
string cultureName

The culture name, e.g. "nb-NO" -or just "FR"

string cultureUiName

Resource strings will use the cultureUiName for translating.

See Also
IResourceProvider

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
ObjectExtensions.AssignByReflection<T>(T, T)
ObjectExtensions.GraphCopy<T>(T)

See Also

IResourceProvider
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top