ソースを参照

程序配置信息增加接口设计中...

于正洋 5 年 前
コミット
f84bc1ea4d

+ 1 - 0
Azylee.Utils/Azylee.Jsons/Azylee.Jsons.csproj

@@ -46,6 +46,7 @@
   <ItemGroup>
   <ItemGroup>
     <Compile Include="ConvertJson.cs" />
     <Compile Include="ConvertJson.cs" />
     <Compile Include="Json.cs" />
     <Compile Include="Json.cs" />
+    <Compile Include="JsonConfigUtils\IJsonConfigModel.cs" />
     <Compile Include="JsonConfigUtils\JsonConfig.cs" />
     <Compile Include="JsonConfigUtils\JsonConfig.cs" />
     <Compile Include="JsonFormat.cs" />
     <Compile Include="JsonFormat.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />

+ 18 - 0
Azylee.Utils/Azylee.Jsons/JsonConfigUtils/IJsonConfigModel.cs

@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.Jsons.JsonConfigUtils
+{
+    /// <summary>
+    /// Json 配置管理器 指定模型接口
+    /// </summary>
+    public interface IJsonConfigModel
+    {
+        /// <summary>
+        /// 重置配置项
+        /// </summary>
+        void Reset();
+    }
+}

+ 3 - 1
Azylee.Utils/Azylee.Jsons/JsonConfigUtils/JsonConfig.cs

@@ -12,7 +12,7 @@ namespace Azylee.Jsons.JsonConfigUtils
     /// Json 配置管理器
     /// Json 配置管理器
     /// </summary>
     /// </summary>
     /// <typeparam name="T"></typeparam>
     /// <typeparam name="T"></typeparam>
-    public class JsonConfig<T> where T : new()
+    public class JsonConfig<T> where T : IJsonConfigModel, new()
     {
     {
         private T Config { get; set; }
         private T Config { get; set; }
         private string FilePath { get; set; }
         private string FilePath { get; set; }
@@ -46,6 +46,8 @@ namespace Azylee.Jsons.JsonConfigUtils
             {
             {
                 this.Config = new T();
                 this.Config = new T();
             }
             }
+            // 重置配置项
+            this.Config.Reset();
             Save();
             Save();
         }
         }
         /// <summary>
         /// <summary>