public void SaveUserConfig(JsonUserConfiguration config, string file) { var json = JsonConvert.SerializeObject(config, Formatting.Indented, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }); WriteEntireFile(file, json); }
public JsonUserConfiguration LoadUserConfig(string file) { var fileContents = ReadEntireFile(file); if (fileContents == null) { return(JsonUserConfiguration.BuildDefaultSettings()); } try { return(JsonConvert.DeserializeObject <JsonUserConfiguration>(fileContents) ?? JsonUserConfiguration.BuildDefaultSettings()); } catch (Exception e) { Log.Error(e, "Loading config failed."); throw; } }