Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 public void Post([FromBody] SuluConfig value)
 {
     Configuration.SaveConfiguration(value);
 }