private void OnChange(MsConfig config) { if (config != null) { Data = config.ConvertToConfig(_source.Key) .ToDictionary(kvp => kvp.Key, kvp => kvp.Value, StringComparer.OrdinalIgnoreCase); OnReload(); } }
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); })); }
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()); }