Exemple #1
0
        private static bool TryGet(Dictionary <string, string> argsDict, string key, ConfigurationSources sources, out string value)
        {
            bool   got = false;
            string val = string.Empty;

            if (sources.HasFlag(ConfigurationSources.CommandLine))
            {
                got = argsDict.TryGetValue(key, out val);
            }

            if (!got && sources.HasFlag(ConfigurationSources.AppConfig))
            {
                val = ConfigurationManager.AppSettings[key];
                if (!string.IsNullOrWhiteSpace(val))
                {
                    got = true;
                }
            }

            if (!got && sources.HasFlag(ConfigurationSources.Environment))
            {
                val = Environment.GetEnvironmentVariable(key);
                got = !string.IsNullOrWhiteSpace(val);
            }

            value = val;
            return(got);
        }
Exemple #2
0
 static IEnumerable <ConfigurationSources> GetLocations(ConfigurationSources input)
 {
     foreach (ConfigurationSources value in Enum.GetValues(input.GetType()))
     {
         if (input.HasFlag(value))
         {
             yield return(value);
         }
     }
 }