tune
This commit is contained in:
@@ -87,7 +87,7 @@
|
||||
<article data-uid="">
|
||||
<h1 id="about-xml-io">About XML IO</h1>
|
||||
|
||||
<p>The XML IO design pattern in Hi Framework is based on <a class="xref" href="../../../../api/Hi.Common.XmlUtils.IMakeXmlSource.html">IMakeXmlSource</a> interface and <a class="xref" href="../../../../api/Hi.Common.XmlUtils.XFactory.html">XFactory</a> class. This pattern provides a standardized way to serialize and deserialize objects to and from XML format.</p>
|
||||
<p>The XML IO design pattern in HiNc Framework is based on <a class="xref" href="../../../../api/Hi.Common.XmlUtils.IMakeXmlSource.html">IMakeXmlSource</a> interface and <a class="xref" href="../../../../api/Hi.Common.XmlUtils.XFactory.html">XFactory</a> class. This pattern provides a standardized way to serialize and deserialize objects to and from XML format.</p>
|
||||
<p>Don't serialize the runtime member object like <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.func-1">Func<TResult></a> or <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.action">Action</a> either cache object. The runtime objects can be optionally sent by the res part on the XFactory Registration or set by the other host or dependent object. If it is set by the other object, then there is nothing can do to it in the XML IO procedure.</p>
|
||||
<h2 id="core-components">Core Components</h2>
|
||||
<h3 id="imakexmlsource-interface">IMakeXmlSource Interface</h3>
|
||||
@@ -95,7 +95,7 @@
|
||||
<h3 id="xfactory-registration">XFactory Registration</h3>
|
||||
<p>Every class implementing IMakeXmlSource must:</p>
|
||||
<ol>
|
||||
<li>Define a static XName property matching the class name</li>
|
||||
<li>Define a static XName property matching the class name.</li>
|
||||
<li>Register itself in the static constructor using XFactory.Regs.Add</li>
|
||||
<li>Implement XML serialization and deserialization logic</li>
|
||||
</ol>
|
||||
@@ -271,41 +271,12 @@ public XElement MakeXmlSource(string baseDirectory, string relFile, bool exhibit
|
||||
}
|
||||
</code></pre><h2 id="best-practices">Best Practices</h2>
|
||||
<ol>
|
||||
<li><strong>XName</strong>: Always define static XName property matching the class name</li>
|
||||
<li><strong>Registration</strong>: Register in static constructor using XFactory.Regs.Add</li>
|
||||
<li><strong>XName</strong>: Always define static XName property matching the class name.</li>
|
||||
<li><strong>Registration</strong>: Register in static constructor using <a class="xref" href="../../../../api/Hi.Common.XmlUtils.XFactory.html">XFactory</a>.Regs</li>
|
||||
<li>Call the XName such like <code>_ = CalleeClass.XName;</code> in the caller class static initailization field so that the registration takes effect before calling the Callee construction by <a class="xref" href="../../../../api/Hi.Common.XmlUtils.XFactory.html">XFactory</a>.</li>
|
||||
<li><strong>Error Handling</strong>: Use appropriate <a class="xref" href="../../../../api/Hi.Common.XmlUtils.GenMode.html">GenMode</a></li>
|
||||
<li><strong>Legacy Support</strong>: Maintain backward compatibility when needed</li>
|
||||
<li><strong>Documentation</strong>: Include XML comments for properties and methods</li>
|
||||
</ol>
|
||||
<h2 id="generation-modes">Generation Modes</h2>
|
||||
<p>The <a class="xref" href="../../../../api/Hi.Common.XmlUtils.GenMode.html">GenMode</a> enumeration provides:</p>
|
||||
<ul>
|
||||
<li><a class="xref" href="../../../../api/Hi.Common.XmlUtils.GenMode.html#Hi_Common_XmlUtils_GenMode_None">None</a></li>
|
||||
<li><a class="xref" href="../../../../api/Hi.Common.XmlUtils.GenMode.html#Hi_Common_XmlUtils_GenMode_Catch">Catch</a></li>
|
||||
<li><a class="xref" href="../../../../api/Hi.Common.XmlUtils.GenMode.html#Hi_Common_XmlUtils_GenMode_Rebase">Rebase</a></li>
|
||||
<li><a class="xref" href="../../../../api/Hi.Common.XmlUtils.GenMode.html#Hi_Common_XmlUtils_GenMode_Default">Default</a></li>
|
||||
</ul>
|
||||
<h2 id="common-usage-patterns">Common Usage Patterns</h2>
|
||||
<ol>
|
||||
<li><strong>Simple Object Generation</strong>:</li>
|
||||
</ol>
|
||||
<pre><code class="lang-csharp">var obj = XFactory.Gen<MyType>(xmlElement, baseDir, null, GenMode.Default);
|
||||
</code></pre>
|
||||
<ol start="2">
|
||||
<li><strong>File-Based Generation</strong>:</li>
|
||||
</ol>
|
||||
<pre><code class="lang-csharp">var obj = XFactory.GenByFile<MyType>(baseDir, relativeFile, GenMode.Default);
|
||||
</code></pre>
|
||||
<ol start="3">
|
||||
<li><strong>XML Source and File Generation</strong>:</li>
|
||||
</ol>
|
||||
<pre><code class="lang-csharp">var xmlSourceAndFile = XFactory.GenXmlSourceAndFile<MyType>(xmlElement, baseDir, null, GenMode.Default);
|
||||
</code></pre>
|
||||
<ol start="4">
|
||||
<li><strong>Hierarchical Object Generation</strong>:</li>
|
||||
</ol>
|
||||
<pre><code class="lang-csharp">var childObj = XFactory.GenByChild<IStructureMaterial>(parentElement, baseDir, null, GenMode.Default);
|
||||
</code></pre>
|
||||
|
||||
</article>
|
||||
|
||||
|
||||
+2
-2
@@ -90,13 +90,13 @@
|
||||
<h2 id="overview">Overview</h2>
|
||||
<p>A connection-scoped indexing pattern for referencing backend objects across hierarchical SignalR hub connections.</p>
|
||||
<h2 id="core-components">Core Components</h2>
|
||||
<p><strong><xref:HiNC_2025_webapi.Common.DictionaryService></strong>: Manages connection-scoped index dictionaries</p>
|
||||
<p><code>DictionaryService</code>: Manages connection-scoped index dictionaries</p>
|
||||
<ul>
|
||||
<li>First layer key: Hub connectionId (auto-generated by SignalR)</li>
|
||||
<li>Second layer key: LocalId (resource name)</li>
|
||||
<li>Value: References to backend objects (functions, getters/setters)</li>
|
||||
</ul>
|
||||
<p><strong><xref:HiNC_2025_webapi.Common.DictionaryHub></strong>: Base hub that auto-cleans index entries on disconnect</p>
|
||||
<p><code>DictionaryHub</code>: Base hub that auto-cleans index entries on disconnect</p>
|
||||
<h2 id="architecture">Architecture</h2>
|
||||
<pre><code>Root-Hub
|
||||
└── Child-Hub - has parent's connectionId
|
||||
|
||||
@@ -131,6 +131,8 @@ catch (Exception ex)
|
||||
<p>See <a href="widget/gui-file-path-assignment.html">GUI File Path Assignment</a>.</p>
|
||||
<h2 id="numeric-inputoutput-handling">Numeric Input/Output Handling</h2>
|
||||
<p>Implement a <code>numeric-utils.js</code> module to handle special floating-point values in web forms. See <a href="widget/numeric-io-utilities.html">Numeric Input/Output Utilities</a> for implementation details.</p>
|
||||
<h2 id="dictionaryservice-pattern-for-hierarchical-components">DictionaryService Pattern for Hierarchical Components</h2>
|
||||
<p>For web applications with hierarchical SignalR hub connections, use the <a href="common/dictionary-service-pattern.html">DictionaryService and DictionaryHub Pattern</a> to manage connection-scoped object indexing. This pattern provides isolation between components, supports nested components without conflicts, and ensures automatic cleanup of resources on disconnect.</p>
|
||||
<h2 id="translation-remarks">Translation Remarks</h2>
|
||||
<p>See <a href="translation-remarks.html">Translation Remarks</a>.</p>
|
||||
|
||||
|
||||
@@ -29,6 +29,16 @@
|
||||
<li>
|
||||
<a href="build-hinc/general-rules.html" name="" title="General Rules">General Rules</a>
|
||||
</li>
|
||||
<li>
|
||||
<span class="expand-stub"></span>
|
||||
<a href="build-hinc/index.html" name="" title="Common Patterns">Common Patterns</a>
|
||||
|
||||
<ul class="nav level3">
|
||||
<li>
|
||||
<a href="build-hinc/common/dictionary-service-pattern.html" name="" title="DictionaryService and DictionaryHub Pattern">DictionaryService and DictionaryHub Pattern</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="build-hinc/initialize-hiapi.html" name="" title="Initialize HiAPI">Initialize HiAPI</a>
|
||||
</li>
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user