Class ResourceUtil
Utility class for working with resource managers and localized strings, and the home of the attribute-declared command vocabulary: the CultureTextAttribute declarations of an assembly, exposed as “type/member + culture → text” queries and as ICommandTextSource instances, with GUI-layer overrides layered on top (SetTextOverride(string, string, string)).
public static class ResourceUtil
- Inheritance
-
ResourceUtil
- Inherited Members
Methods
GenTextSource(CultureInfo, params Type[])
Generates an ICommandTextSource carrying
culture, resolving keys against the
CultureTextAttribute declarations of the
vocabTypes' assemblies plus the registered
overrides — the engine-default localizer a caller injects into
title-composing commands.
public static ICommandTextSource GenTextSource(CultureInfo culture, params Type[] vocabTypes)
Parameters
cultureCultureInfoCulture the source carries; null takes the current UI culture.
vocabTypesType[]Types anchoring the assemblies whose declarations feed the source.
Returns
- ICommandTextSource
The text source.
GetStringOrDefault(ResourceManager, string)
get string by the name as key from resourceManager
The default value is the name itself.
public static string GetStringOrDefault(this ResourceManager resourceManager, string name)
Parameters
resourceManagerResourceManagernamestring
Returns
GetStringOrDefault(ResourceManager, string, CultureInfo)
get string by the name as key from resourceManager
The default value is the name itself.
public static string GetStringOrDefault(this ResourceManager resourceManager, string name, CultureInfo cultureInfo)
Parameters
resourceManagerResourceManagernamestringcultureInfoCultureInfo
Returns
GetText(MemberInfo, CultureInfo)
The text of member's vocabulary key in
culture — the “type/member + culture → text” query.
Resolution walks the culture's parent chain; on each level a
registered override (SetTextOverride(string, string, string)) outranks the
member assembly's CultureTextAttribute declaration. With
no match the key itself — the English default — is returned.
public static string GetText(MemberInfo member, CultureInfo culture)
Parameters
memberMemberInfoThe type or member owning the vocabulary key.
cultureCultureInfoWanted culture; null takes the current UI culture.
Returns
- string
The culture's text, or the key itself.
SetTextOverride(string, string, string)
Registers a GUI-layer text for a vocabulary key in one culture. An override outranks the assembly's own CultureTextAttribute declaration in that culture, and may add a culture the assembly never declared. Process-level; typically called once at GUI startup.
public static void SetTextOverride(string cultureName, string key, string text)