/// <summary> /// Loads the config. /// </summary> static async Task <bool> LoadConfig(IDataPersistence dataPersistence, IConfig config) { var configs = dataPersistence.ReadConfigs(); foreach (var item in configs) { var result = await config.Write(Newtonsoft.Json.JsonConvert.DeserializeObject <Key>(item.Key), Newtonsoft.Json.JsonConvert.DeserializeObject <MyEntity>(item.Value)); if (!result) { throw new Exception("write consul config fault"); } } return(true); }
/// <summary> /// Load configs from data persistence /// </summary> /// <returns></returns> private async Task <bool> LoadConfig() { var dataConfigs = _dataPersistence?.ReadConfigs(); if (dataConfigs == null) { return(false); } else { foreach (var config in dataConfigs) { var result = await CreateUpdateKey(new CreateUpdateKeyParmeter { Key = config.Key, DC = null }, config.Value); if (result.result == false || result.createUpdateResult == false) { return(false); } } return(true); } }