using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace XKRS.Common.Model.Helper { public static class SettingHelper { const string SETTINGFILE = "Setting.json"; //声明一个SettingInfo类型的字段 public static SettingInfo SettingInfo; public static string SettingPath => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SETTINGFILE); /// /// 声明一个静态方法,获取选择的布局 /// /// 返回当前布局 public static string GetSelectLayout() { return SettingInfo.CurrLayout; } /// /// 获取生产代码, /// /// 字符串类型的集合 public static List GetProductionCodes() { if (SettingInfo.ProductionCodes.Count == 0) { SettingInfo.ProductionCodes.Add("Default"); } if (!string.IsNullOrWhiteSpace(SettingInfo.DefaultProduction)) { if (SettingInfo.ProductionCodes.Contains(SettingInfo.DefaultProduction)) { SettingInfo.ProductionCodes.Remove(SettingInfo.DefaultProduction); SettingInfo.ProductionCodes.Insert(0, SettingInfo.DefaultProduction); } } return SettingInfo.ProductionCodes; } /// /// 获取过程代码 /// /// public static List GetProcessCodes() { if (!string.IsNullOrWhiteSpace(SettingInfo.DefaultProcess)) { if (SettingInfo.ProcessCodes.Contains(SettingInfo.DefaultProcess)) { SettingInfo.ProcessCodes.Remove(SettingInfo.DefaultProcess); SettingInfo.ProcessCodes.Insert(0, SettingInfo.DefaultProcess); } } return SettingInfo.ProcessCodes; } } /// /// 设置信息类,声明自动属性 /// public class SettingInfo { public List ProcessCodes { get; set; } = new List(); public List ProductionCodes { get; set; } = new List(); public string DefaultProcess { get; set; } public string DefaultProduction { get; set; } public string CurrLayout { get; set; } = ""; } }