private ApplicationConfig GetApplicationForProtocol(SuluConfig config, string protocol) { var application = config.Protocols.FirstOrDefault(x => x.Protocol == protocol); if (application == null) { return(null); } return(config.Applications.FirstOrDefault(x => x.Id == application.AppId)); }
public SuluConfig SaveConfiguration(SuluConfig configuration) { // TODO: Save the file and keep the comments and formatting // I think this can be done by switching the config file to // json5 and adding a parser for that where we would read the // config as json5 replace the values from the incoming config // object and then write it out again Save(configuration); Load(); return(Config); }
private void Save(SuluConfig configuration) { var configFile = Path.Combine(Constants.GetBinaryDir(), "sulu.json"); var serializerSettings = new JsonSerializerSettings(); serializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); serializerSettings.Formatting = Formatting.Indented; var json = JsonConvert.SerializeObject(configuration, serializerSettings); File.WriteAllText(configFile, json); }
protected void Load() { var configFile = Path.Combine(Constants.GetBinaryDir(), "sulu.json"); if (!File.Exists(configFile)) { Serilog.Log.Warning($"config file not found at: {configFile}"); return; } var configJson = File.ReadAllText(configFile); var serializerSettings = new JsonSerializerSettings(); serializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); var json = JsonConvert.SerializeObject(configJson, serializerSettings); Config = JsonConvert.DeserializeObject <SuluConfig>(configJson); }
public void Post([FromBody] SuluConfig value) { Configuration.SaveConfiguration(value); }