private async Task <bool> RemoveKey(string key) { //data persistence delete key if (_dataPersistence != null) { _dataPersistence.DeleteConfig(key); } //consul remove var keyStrArr = key.Split(new string[] { Key.RegxString }, StringSplitOptions.RemoveEmptyEntries); var backResult = true; if (keyStrArr.Length > 0) { var list = new List <ReadKeyResult>(); list.AddRange(await ReadKey(keyStrArr[0])); foreach (var item in list) { var reg = new Regex($"^{key}$"); if (reg.IsMatch(item.Key)) { var result = await DeleteKey(new DeleteKeyParmeter { Key = item.Key }); backResult = backResult && result.result && result.deleteResult; } } } return(backResult); }
/// <summary> /// Removes the config. /// </summary> static async Task RemoveConfig(IDataPersistence dataPersistence, IConfig config) { var key = new Key { NameSpace = "ns", Environment = "pro", Version = "1.0", Tag = "His" }; var result = dataPersistence.DeleteConfig(key.ToString()); if (result) { await config.Remove(key); } }