public static Config GetInstance() { if (instance == null) { lock (locker) { if (instance == null) { instance = GetConfig(); } } } return instance; }
private static Config GetConfig() { string configStr = CommonHelper.GetConfigStr(path); Config config = null; if (string.IsNullOrEmpty(configStr)) { config = new Config(); string json = JsonConvert.SerializeObject(instance, Formatting.Indented); CommonHelper.SaveConfig(path, json); } else { config = JsonConvert.DeserializeObject<Config>(configStr); } return config; }