From 05ada6189bb2ae53a003703bad5527cdc0d28909 Mon Sep 17 00:00:00 2001 From: iamboss Date: Sun, 24 May 2026 10:34:11 +0800 Subject: [PATCH] refactor(Hi.Sample): convert DemoBuildMachineTool to Reg(XFactory factory=null) Static ctor rewritten as public static void Reg(XFactory factory = null). Part of the workspace-wide ~270-class XFactory refactor; see HiGeom commit for the XFactory instance refactor and full pattern rationale. Co-Authored-By: Claude Opus 4.7 --- MachineTool/DemoBuildMachineTool.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/MachineTool/DemoBuildMachineTool.cs b/MachineTool/DemoBuildMachineTool.cs index 18fb746..38467d2 100644 --- a/MachineTool/DemoBuildMachineTool.cs +++ b/MachineTool/DemoBuildMachineTool.cs @@ -23,9 +23,15 @@ namespace Sample.MachineTool /// public class DemoBuildMachineTool : IGetCodeXyzabcMachineTool { - static DemoBuildMachineTool() + /// + /// Registers this type's deserializer with the given + /// (or when is + /// null). Idempotent. + /// + public static void Reg(XFactory factory = null) { - XFactory.Generators.Add(XName, (xml, baseDirectory, relFile, progress, res) => new DemoBuildMachineTool()); + factory ??= XFactory.Default; + factory.Generators.TryAdd(XName, (xml, baseDirectory, relFile, progress, res) => new DemoBuildMachineTool()); } /// /// Generates an XYZ-ABC machine tool instance from embedded resources.