示例#1
0
        public void SaveUserConfig(JsonUserConfiguration config, string file)
        {
            var json = JsonConvert.SerializeObject(config, Formatting.Indented, new JsonSerializerSettings {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            WriteEntireFile(file, json);
        }
示例#2
0
        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;
            }
        }