diff --git a/SlnMesnac.Config/AppConfig.cs b/SlnMesnac.Config/AppConfig.cs index 1cfc66e..d2b0de6 100644 --- a/SlnMesnac.Config/AppConfig.cs +++ b/SlnMesnac.Config/AppConfig.cs @@ -1,6 +1,9 @@ using Microsoft.Extensions.Options; +using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.IO; +using System.Xml; #region << 版 本 注 释 >> /*-------------------------------------------------------------------- @@ -58,6 +61,27 @@ namespace SlnMesnac.Config /// public string redisConfig { get; set; } + /// + /// 修改配置文件 + /// + /// + public void SetValue(AppConfig appConfig) + { + var jsonObject = JsonConvert.SerializeObject(new + { + AppConfig = new + { + logPath = appConfig.logPath, + SqlConfig = appConfig.sqlConfig, + PlcConfig = appConfig.plcConfig, + RfidConfig = appConfig.rfidConfig, + RedisConfig = appConfig.redisConfig, + } + }, Newtonsoft.Json.Formatting.Indented); + var appSettingsPath = Path.Combine(AppContext.BaseDirectory, "appsettings.json"); + File.WriteAllText(appSettingsPath, jsonObject); + } + public AppConfig Value => this; } } diff --git a/SlnMesnac.Config/SlnMesnac.Config.csproj b/SlnMesnac.Config/SlnMesnac.Config.csproj index 5ed17ce..daf8195 100644 --- a/SlnMesnac.Config/SlnMesnac.Config.csproj +++ b/SlnMesnac.Config/SlnMesnac.Config.csproj @@ -7,6 +7,7 @@ +