namespace Yw.Settings { /// /// 文件辅助类 /// internal class HydroL3dFileHelper { /// /// json文件名称 /// internal static string JsonFileName { get { if (string.IsNullOrEmpty(_jsonFileName)) { _jsonFileName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "paras_hydrol3d_settings.json"); } return _jsonFileName; } } private static string _jsonFileName = null; /// /// 获取 /// internal static HydroL3dParas 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 HydroL3dParas(); } } } } return _appparas; } private static HydroL3dParas _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; } } }