public static T GetSetting <T>(string folder, string fileName) { T result = default(T); string text = SettingExtension.GetPath() + "\\TVDSetting"; string text2 = text + "\\" + folder; bool flag = !Directory.Exists(text); if (flag) { Directory.CreateDirectory(text); } bool flag2 = !Directory.Exists(text2); if (flag2) { Directory.CreateDirectory(text2); } string path = text2 + "\\" + fileName; bool flag3 = File.Exists(path); if (flag3) { using (StreamReader streamReader = File.OpenText(path)) { JsonSerializer jsonSerializer = new JsonSerializer(); result = (T)((object)jsonSerializer.Deserialize(streamReader, typeof(T))); } } return(result); }
public static void SaveSetting <T>(T setting, string folder, string fileName) { string text = SettingExtension.GetPath() + "\\TVDSetting\\" + folder; bool flag = !Directory.Exists(text); if (flag) { Directory.CreateDirectory(text); } string path = text + "\\" + fileName; string contents = string.Empty; contents = JsonConvert.SerializeObject(setting, Formatting.Indented); File.WriteAllText(path, contents); }