private void OnChange(MsConfig config)
 {
     if (config != null)
     {
         Data = config.ConvertToConfig(_source.Key)
                .ToDictionary(kvp => kvp.Key, kvp => kvp.Value, StringComparer.OrdinalIgnoreCase);
         OnReload();
     }
 }
Esempio n. 2
0
        internal static IEnumerable <KeyValuePair <string, string> > ConvertToConfig(
            this MsConfig kvPair,
            string rootKey)
        {
            return(JsonConfigurationFileParser.Parse(kvPair.Value).Select(pair =>
            {
                string key = $"{kvPair.Key}:{pair.Key}";

                return new KeyValuePair <string, string>(key, pair.Value);
            }));
        }
Esempio n. 3
0
 public IActionResult SaveConfig(MsConfig model)
 {
     if (model.Id == 0)
     {
         _configRepository.Insert(model);
     }
     else
     {
         _configRepository.DyUpdate(new
         {
             model.Id,
             model.Key,
             Value = JsonConvert.SerializeObject(JsonConvert.DeserializeObject <Dictionary <string, object> >(model.Value)),
             model.Status,
             model.App,
             UpdateTime = DateTime.Now
         });
     }
     return(Json());
 }