Archived
404 lines
16 KiB
HTML
404 lines
16 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Class ResourceUtil | HiAPI-C# 2025 </title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="title" content="Class ResourceUtil | HiAPI-C# 2025 ">
|
|
|
|
<meta name="description" content="Utility class for working with resource managers and localized strings, and the home of the attribute-declared command vocabulary: the declarations of an assembly, exposed as &ldquo;type/member + culture → text&rdquo; queries and as instances, with GUI-layer overrides layered on top ().">
|
|
<link rel="icon" href="../img/HiAPI.favicon.ico">
|
|
<link rel="stylesheet" href="../public/docfx.min.css">
|
|
<link rel="stylesheet" href="../public/main.css">
|
|
<meta name="docfx:navrel" content="../toc.html">
|
|
<meta name="docfx:tocrel" content="toc.html">
|
|
|
|
<meta name="docfx:rel" content="../">
|
|
|
|
|
|
|
|
<meta name="loc:inThisArticle" content="In this article">
|
|
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
|
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
|
<meta name="loc:tocFilter" content="Filter by title">
|
|
<meta name="loc:nextArticle" content="Next">
|
|
<meta name="loc:prevArticle" content="Previous">
|
|
<meta name="loc:themeLight" content="Light">
|
|
<meta name="loc:themeDark" content="Dark">
|
|
<meta name="loc:themeAuto" content="Auto">
|
|
<meta name="loc:changeTheme" content="Change theme">
|
|
<meta name="loc:copy" content="Copy">
|
|
<meta name="loc:downloadPdf" content="Download PDF">
|
|
|
|
<script type="module" src="./../public/docfx.min.js"></script>
|
|
|
|
<script>
|
|
const theme = localStorage.getItem('theme') || 'auto'
|
|
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
|
|
<header class="bg-body border-bottom">
|
|
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
|
<div class="container-xxl flex-nowrap">
|
|
<a class="navbar-brand" href="../index.html">
|
|
<img id="logo" class="svg" src="../img/HiAPI.logo.png" alt="">
|
|
|
|
</a>
|
|
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
|
<i class="bi bi-three-dots"></i>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navpanel">
|
|
<div id="navbar">
|
|
<form class="search" role="search" id="search">
|
|
<i class="bi bi-search"></i>
|
|
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
</header>
|
|
|
|
<main class="container-xxl">
|
|
<div class="toc-offcanvas">
|
|
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
|
<div class="offcanvas-header">
|
|
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
|
</div>
|
|
<div class="offcanvas-body">
|
|
<nav class="toc" id="toc"></nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="content">
|
|
<div class="actionbar">
|
|
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
|
<i class="bi bi-list"></i>
|
|
</button>
|
|
|
|
<nav id="breadcrumb"></nav>
|
|
</div>
|
|
|
|
<article data-uid="Hi.Common.ResourceUtil">
|
|
|
|
|
|
|
|
<h1 id="Hi_Common_ResourceUtil" data-uid="Hi.Common.ResourceUtil" class="text-break">
|
|
Class ResourceUtil
|
|
</h1>
|
|
|
|
<div class="facts text-secondary">
|
|
<dl><dt>Namespace</dt><dd><a class="xref" href="Hi.html">Hi</a>.<a class="xref" href="Hi.Common.html">Common</a></dd></dl>
|
|
<dl><dt>Assembly</dt><dd>HiGeom.dll</dd></dl>
|
|
</div>
|
|
|
|
<div class="markdown summary"><p>Utility class for working with resource managers and localized strings,
|
|
and the home of the attribute-declared command vocabulary: the
|
|
<a class="xref" href="Hi.Common.CultureTextAttribute.html">CultureTextAttribute</a> declarations of an assembly, exposed as
|
|
“type/member + culture → text” queries and as
|
|
<a class="xref" href="Hi.Common.ICommandTextSource.html">ICommandTextSource</a> instances, with GUI-layer overrides
|
|
layered on top (<a class="xref" href="Hi.Common.ResourceUtil.html#Hi_Common_ResourceUtil_SetTextOverride_System_String_System_String_System_String_">SetTextOverride(string, string, string)</a>).</p>
|
|
</div>
|
|
<div class="markdown conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static class ResourceUtil</code></pre>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<dl class="typelist inheritance">
|
|
<dt>Inheritance</dt>
|
|
<dd>
|
|
<div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
|
|
<div><span class="xref">ResourceUtil</span></div>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
<dl class="typelist inheritedMembers">
|
|
<dt>Inherited Members</dt>
|
|
<dd>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object)</a>
|
|
</div>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object, object)</a>
|
|
</div>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a>
|
|
</div>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>
|
|
</div>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>
|
|
</div>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object, object)</a>
|
|
</div>
|
|
<div>
|
|
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2 class="section" id="methods">Methods
|
|
</h2>
|
|
|
|
|
|
<a id="Hi_Common_ResourceUtil_GenTextSource_" data-uid="Hi.Common.ResourceUtil.GenTextSource*"></a>
|
|
|
|
<h3 id="Hi_Common_ResourceUtil_GenTextSource_System_Globalization_CultureInfo_System_Type___" data-uid="Hi.Common.ResourceUtil.GenTextSource(System.Globalization.CultureInfo,System.Type[])">
|
|
GenTextSource(CultureInfo, params Type[])
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Generates an <a class="xref" href="Hi.Common.ICommandTextSource.html">ICommandTextSource</a> carrying
|
|
<code class="paramref">culture</code>, resolving keys against the
|
|
<a class="xref" href="Hi.Common.CultureTextAttribute.html">CultureTextAttribute</a> declarations of the
|
|
<code class="paramref">vocabTypes</code>' assemblies plus the registered
|
|
overrides — the engine-default localizer a caller injects into
|
|
title-composing commands.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static ICommandTextSource GenTextSource(CultureInfo culture, params Type[] vocabTypes)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>culture</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo">CultureInfo</a></dt>
|
|
<dd><p>Culture the source carries; null takes the current UI culture.</p>
|
|
</dd>
|
|
<dt><code>vocabTypes</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.type">Type</a>[]</dt>
|
|
<dd><p>Types anchoring the assemblies whose declarations feed the source.</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="Hi.Common.ICommandTextSource.html">ICommandTextSource</a></dt>
|
|
<dd><p>The text source.</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_ResourceUtil_GetStringOrDefault_" data-uid="Hi.Common.ResourceUtil.GetStringOrDefault*"></a>
|
|
|
|
<h3 id="Hi_Common_ResourceUtil_GetStringOrDefault_System_Resources_ResourceManager_System_String_" data-uid="Hi.Common.ResourceUtil.GetStringOrDefault(System.Resources.ResourceManager,System.String)">
|
|
GetStringOrDefault(ResourceManager, string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>get string by the <code class="paramref">name</code> as key from <code class="paramref">resourceManager</code>
|
|
The default value is the <code class="paramref">name</code> itself.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string GetStringOrDefault(this ResourceManager resourceManager, string name)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>resourceManager</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.resources.resourcemanager">ResourceManager</a></dt>
|
|
<dd></dd>
|
|
<dt><code>name</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd></dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd></dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_ResourceUtil_GetStringOrDefault_" data-uid="Hi.Common.ResourceUtil.GetStringOrDefault*"></a>
|
|
|
|
<h3 id="Hi_Common_ResourceUtil_GetStringOrDefault_System_Resources_ResourceManager_System_String_System_Globalization_CultureInfo_" data-uid="Hi.Common.ResourceUtil.GetStringOrDefault(System.Resources.ResourceManager,System.String,System.Globalization.CultureInfo)">
|
|
GetStringOrDefault(ResourceManager, string, CultureInfo)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>get string by the <code class="paramref">name</code> as key from <code class="paramref">resourceManager</code>
|
|
The default value is the <code class="paramref">name</code> itself.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string GetStringOrDefault(this ResourceManager resourceManager, string name, CultureInfo cultureInfo)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>resourceManager</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.resources.resourcemanager">ResourceManager</a></dt>
|
|
<dd></dd>
|
|
<dt><code>name</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd></dd>
|
|
<dt><code>cultureInfo</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo">CultureInfo</a></dt>
|
|
<dd></dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd></dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_ResourceUtil_GetText_" data-uid="Hi.Common.ResourceUtil.GetText*"></a>
|
|
|
|
<h3 id="Hi_Common_ResourceUtil_GetText_System_Reflection_MemberInfo_System_Globalization_CultureInfo_" data-uid="Hi.Common.ResourceUtil.GetText(System.Reflection.MemberInfo,System.Globalization.CultureInfo)">
|
|
GetText(MemberInfo, CultureInfo)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>The text of <code class="paramref">member</code>'s vocabulary key in
|
|
<code class="paramref">culture</code> — the “type/member + culture → text” query.
|
|
Resolution walks the culture's parent chain; on each level a
|
|
registered override (<a class="xref" href="Hi.Common.ResourceUtil.html#Hi_Common_ResourceUtil_SetTextOverride_System_String_System_String_System_String_">SetTextOverride(string, string, string)</a>) outranks the
|
|
member assembly's <a class="xref" href="Hi.Common.CultureTextAttribute.html">CultureTextAttribute</a> declaration. With
|
|
no match the key itself — the English default — is returned.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static string GetText(MemberInfo member, CultureInfo culture)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>member</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.reflection.memberinfo">MemberInfo</a></dt>
|
|
<dd><p>The type or member owning the vocabulary key.</p>
|
|
</dd>
|
|
<dt><code>culture</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.globalization.cultureinfo">CultureInfo</a></dt>
|
|
<dd><p>Wanted culture; null takes the current UI culture.</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<h4 class="section">Returns</h4>
|
|
<dl class="parameters">
|
|
<dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The culture's text, or the key itself.</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a id="Hi_Common_ResourceUtil_SetTextOverride_" data-uid="Hi.Common.ResourceUtil.SetTextOverride*"></a>
|
|
|
|
<h3 id="Hi_Common_ResourceUtil_SetTextOverride_System_String_System_String_System_String_" data-uid="Hi.Common.ResourceUtil.SetTextOverride(System.String,System.String,System.String)">
|
|
SetTextOverride(string, string, string)
|
|
|
|
</h3>
|
|
|
|
<div class="markdown level1 summary"><p>Registers a GUI-layer text for a vocabulary key in one culture. An
|
|
override outranks the assembly's own <a class="xref" href="Hi.Common.CultureTextAttribute.html">CultureTextAttribute</a>
|
|
declaration in that culture, and may add a culture the assembly never
|
|
declared. Process-level; typically called once at GUI startup.</p>
|
|
</div>
|
|
<div class="markdown level1 conceptual"></div>
|
|
|
|
<div class="codewrapper">
|
|
<pre><code class="lang-csharp hljs">public static void SetTextOverride(string cultureName, string key, string text)</code></pre>
|
|
</div>
|
|
|
|
<h4 class="section">Parameters</h4>
|
|
<dl class="parameters">
|
|
<dt><code>cultureName</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>Culture name the text is written in (e.g. <code>zh-Hant</code>).</p>
|
|
</dd>
|
|
<dt><code>key</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>Vocabulary key — the English default text.</p>
|
|
</dd>
|
|
<dt><code>text</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
|
|
<dd><p>The overriding text; null removes the override.</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</article>
|
|
|
|
<div class="contribution d-print-none">
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
<div class="affix">
|
|
<nav id="affix"></nav>
|
|
</div>
|
|
</main>
|
|
|
|
<div class="container-xxl search-results" id="search-results"></div>
|
|
|
|
<footer class="border-top text-secondary">
|
|
<div class="container-xxl">
|
|
<div class="flex-fill">
|
|
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html>
|