Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
        string GetFullKey(string key)
        {
            string theKey = NameBuilder.GetSettingName(HostName, Environment, Machine.NotSpecified, key.ToLower()).ToLower();

            return(theKey);
        }
Ejemplo n.º 4
0
        public void Delete(string settingKey, IPandoraContext applicationContex)
        {
            var settingName = NameBuilder.GetSettingName(applicationContex.ApplicationName, applicationContex.Cluster, applicationContex.Machine, settingKey);

            cfgRepo.Delete(settingName);
        }
Ejemplo n.º 5
0
 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));
 }
Ejemplo n.º 6
0
 public static string CreatePandoraRawKey(this string settingKey)
 {
     return(NameBuilder.GetSettingName("Elders.Pandora.Consul.Tests", "test", Elders.Pandora.Box.Machine.NotSpecified, settingKey));
 }