Table of Contents

Class ResourceUtil

Namespace
Hi.Common
Assembly
HiGeom.dll

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

culture CultureInfo

Culture the source carries; null takes the current UI culture.

vocabTypes Type[]

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

resourceManager ResourceManager
name string

Returns

string

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

resourceManager ResourceManager
name string
cultureInfo CultureInfo

Returns

string

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

member MemberInfo

The type or member owning the vocabulary key.

culture CultureInfo

Wanted 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)

Parameters

cultureName string

Culture name the text is written in (e.g. zh-Hant).

key string

Vocabulary key — the English default text.

text string

The overriding text; null removes the override.