namespace IStation.Settings { internal class SZJTFileHelper { /// /// json文件名称 /// internal static string JsonFileName { get { if (string.IsNullOrEmpty(_jsonFileName)) { _jsonFileName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "paras_szjt_settings.json"); } return _jsonFileName; } } private static string _jsonFileName = null; /// /// 获取 /// internal static SZJTParas Get() { if (_appparas == null) { lock (_locker) { if (_appparas == null) { var json = File.ReadAllText(JsonFileName, Encoding.UTF8); _appparas = JsonHelper.Json2Object(json); if (_appparas == null) { _appparas = new SZJTParas(); } } } } return _appparas; } private static SZJTParas _appparas = null; private static readonly object _locker = new object(); /// /// 保存 /// /// internal static bool Save() { if (_appparas == null) return default; var json = JsonHelper.Object2FormatJson(_appparas); File.WriteAllText(JsonFileName, json, Encoding.UTF8); return true; } } }