From 53106cd3c0ca15b0b2fb08cb82f8086f305a19f7 Mon Sep 17 00:00:00 2001
From: duheng <2784771470@qq.com>
Date: 星期日, 18 八月 2024 19:42:26 +0800
Subject: [PATCH] 添加泵型号选择

---
 Service/HStation.Service.Assets.Core/03-settings/00-core/XhsFileHelper.cs |   65 ++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/Service/HStation.Service.Assets.Core/03-settings/00-core/XhsFileHelper.cs b/Service/HStation.Service.Assets.Core/03-settings/00-core/XhsFileHelper.cs
new file mode 100644
index 0000000..d83765e
--- /dev/null
+++ b/Service/HStation.Service.Assets.Core/03-settings/00-core/XhsFileHelper.cs
@@ -0,0 +1,65 @@
+锘縰sing System.Text;
+
+namespace HStation.Settings
+{
+    internal class XhsFileHelper
+    {
+        /// <summary>
+        /// json鏂囦欢鍚嶇О
+        /// </summary>
+        internal static string JsonFileName
+        {
+            get
+            {
+                if (string.IsNullOrEmpty(_jsonFileName))
+                {
+                    _jsonFileName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "paras_xhs_settings.json");
+                }
+                return _jsonFileName;
+            }
+        }
+
+        private static string _jsonFileName = null;
+
+        /// <summary>
+        /// 鑾峰彇
+        /// </summary>
+        internal static XhsParas Get()
+        {
+            if (_appparas == null)
+            {
+                lock (_locker)
+                {
+                    if (_appparas == null)
+                    {
+                        var json = File.ReadAllText(JsonFileName, Encoding.UTF8);
+                        _appparas = JsonHelper.Json2Object<XhsParas>(json);
+                        if (_appparas == null)
+                        {
+                            _appparas = new XhsParas();
+                        }
+                    }
+                }
+            }
+            return _appparas;
+        }
+
+        private static XhsParas _appparas = null;
+        private static readonly object _locker = new object();
+
+        /// <summary>
+        /// 淇濆瓨
+        /// </summary>
+        /// <returns></returns>
+        internal static bool Save()
+        {
+            if (_appparas == null)
+            {
+                return default;
+            }
+            var json = JsonHelper.Object2FormatJson(_appparas);
+            File.WriteAllText(JsonFileName, json, Encoding.UTF8);
+            return true;
+        }
+    }
+}
\ No newline at end of file

--
Gitblit v1.9.3