From 559890c482f5973f06aafdfec9550fee5ba3c7f2 Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 09 十一月 2026 17:02:15 +0800
Subject: [PATCH] feat: CAN 模拟器 TCP 化 + 多设备并发调试 + 后台生命周期管理

---
 Plugin.DeviceConfig/V3AuthorityCatalog.cs |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/Plugin.DeviceConfig/V3AuthorityCatalog.cs b/Plugin.DeviceConfig/V3AuthorityCatalog.cs
new file mode 100644
index 0000000..25f5126
--- /dev/null
+++ b/Plugin.DeviceConfig/V3AuthorityCatalog.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Configuration;
+using System.Linq;
+
+namespace Plugin.DeviceConfig
+{
+    /// <summary>
+    /// V3.0 浠茶鍩� / Broker 瀹夸富鍊欓�夋灇涓俱��
+    /// 鍊欓�夊�间粠瀹夸富閰嶇疆鏂囦欢 appSettings 璇诲彇锛堥敭锛歏3.AuthorityIds / V3.BrokerIds锛屽垎鍙峰垎闅旓級锛�
+    /// 鏈厤缃椂鍥為��鍐呯疆榛樿鍊硷紝涓� InfrastructureBootstrapper 鐨勬湰鍦颁徊瑁佸煙 "local-main" 淇濇寔涓�鑷淬��
+    /// </summary>
+    public static class V3AuthorityCatalog
+    {
+        private const string FallbackAuthorityIds = "local-main;broker-b01";
+        private const string FallbackBrokerIds = "broker-b01";
+
+        /// <summary>鍏ㄩ儴鍚堟硶浠茶鍩熸爣璇嗭紙Local 鍩熶互 local- 鍓嶇紑鏍囪瘑锛孊roker 鍩熷嵆鍚� Broker 鑷韩锛�</summary>
+        public static string[] AuthorityIds => Read("V3.AuthorityIds", FallbackAuthorityIds);
+
+        /// <summary>鍏ㄩ儴鍚堟硶 Broker 瀹夸富鏍囪瘑</summary>
+        public static string[] BrokerIds => Read("V3.BrokerIds", FallbackBrokerIds);
+
+        /// <summary>鏈満榛樿 Local 浠茶鍩燂紙鍊欓�夋灇涓句腑绗竴涓� local- 鍓嶇紑椤癸級</summary>
+        public static string LocalAuthorityId =>
+            AuthorityIds.FirstOrDefault(a => a.StartsWith("local-", StringComparison.OrdinalIgnoreCase))
+            ?? AuthorityIds[0];
+
+        /// <summary>鍒ゆ柇缁欏畾鏍囪瘑鏄惁涓� Local 浠茶鍩�</summary>
+        public static bool IsLocalAuthority(string? authorityId) =>
+            !string.IsNullOrWhiteSpace(authorityId) &&
+            authorityId!.StartsWith("local-", StringComparison.OrdinalIgnoreCase);
+
+        private static string[] Read(string key, string fallback)
+        {
+            string? raw = null;
+            try
+            {
+                raw = ConfigurationManager.AppSettings[key];
+            }
+            catch
+            {
+                // 瀹夸富鏈彁渚涢厤缃枃浠舵椂闈欓粯鍥為��榛樿鏋氫妇
+            }
+            // net472 寮曠敤绋嬪簭闆嗘棤 NotNullWhen 鏍囨敞锛屾樉寮忓洖閫�鍚庤В寮曠敤
+            var value = string.IsNullOrWhiteSpace(raw) ? fallback : raw!;
+            return value.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
+                      .Select(s => s.Trim())
+                      .Where(s => s.Length > 0)
+                      .ToArray();
+        }
+    }
+}

--
Gitblit v1.9.1