string GetSetting(string key) { string theKey = NameBuilder.GetSettingName(HostName, Environment, Machine.NotSpecified, key.ToLower()).ToLower(); if (!configuration.ContainsKey(theKey)) { throw new KeyNotFoundException($"The corresponding key is missing - {theKey}"); } string theValue = (string)configuration[theKey]; string parameterPattern = @"\${(.*?)}"; var regex = new Regex(parameterPattern, RegexOptions.IgnoreCase); Match match = regex.Match(theValue); if (match.Success) { string wrappedKey = match.Value; string internalKey = match.Groups[1].Value; string internalValue = GetSetting(internalKey); string evaluated = theValue.Replace(wrappedKey, internalValue); return(evaluated); } return(theValue); }
public string Get(string settingKey, IPandoraContext applicationContext) { if (string.IsNullOrEmpty(settingKey)) { throw new ArgumentNullException(nameof(settingKey)); } if (ReferenceEquals(null, applicationContext)) { throw new ArgumentNullException(nameof(applicationContext)); } var sanitizedKey = settingKey.ToLower(); string keyForMachine = NameBuilder.GetSettingName(applicationContext.ApplicationName, applicationContext.Cluster, applicationContext.Machine, sanitizedKey); if (cfgRepo.Exists(keyForMachine)) { return(cfgRepo.Get(keyForMachine)); } else { string keyForCluster = NameBuilder.GetSettingName(applicationContext.ApplicationName, applicationContext.Cluster, Machine.NotSpecified, sanitizedKey); return(cfgRepo.Get(keyForCluster)); } }
string GetFullKey(string key) { string theKey = NameBuilder.GetSettingName(HostName, Environment, Machine.NotSpecified, key.ToLower()).ToLower(); return(theKey); }
public void Delete(string settingKey, IPandoraContext applicationContex) { var settingName = NameBuilder.GetSettingName(applicationContex.ApplicationName, applicationContex.Cluster, applicationContex.Machine, settingKey); cfgRepo.Delete(settingName); }
Dictionary <string, object> NamenizeConfiguration(Dictionary <string, object> settings, string clusterName, string machineName) { return(settings.ToDictionary(x => NameBuilder.GetSettingName(box.Name, clusterName, machineName, x.Key), y => y.Value)); }
public static string CreatePandoraRawKey(this string settingKey) { return(NameBuilder.GetSettingName("Elders.Pandora.Consul.Tests", "test", Elders.Pandora.Box.Machine.NotSpecified, settingKey)); }