Exemple #1
0
 /// <summary>
 /// Adds all environment variables into the <see cref="Configuration"/>.
 /// When a configuration item exists, the value is updated.
 /// </summary>
 /// <remarks>
 /// The name of the environment variable is used as a key to the configuration item.
 /// Use the "dot notation" in variable names to support the configuration hierarchy.
 /// </remarks>
 /// <returns>The current <see cref="ConfigurationBuilder"/></returns>
 public ConfigurationBuilder AddEnvironmentVariables()
 {
     foreach (DictionaryEntry entry in Environment.GetEnvironmentVariables())
     {
         Instance.AddOrUpdateItem(entry.Key.ToString(), entry.Value);
     }
     return(this);
 }
Exemple #2
0
        public static IDictionary <string, string> BuildConfig(ref string[] args)
        {
            var all = new IEnumerable[] {
                // Inject framework information...
                ConfigHelper.ReflectObjToDict(Env.OSVersion, prefix: "o"),
                ConfigHelper.ReflectToDict(typeof(Env), prefix: "n")
                .Where(e => !e.Key.Contains("StackTrace")),
                ConfigHelper.InvokeToDict(ConfigHelper.GetEnumValues <SpecialFolder>(),
                                          o => Env.GetFolderPath(o), prefix: "p"),
                ConfigHelper.ReflectObjToDict(DateTime.Now, prefix: "t"),
                // Inject environment variables...
                ConfigHelper.Normalize(Env.GetEnvironmentVariables(EnvTgt.Machine), prefix: "e"),
                ConfigHelper.Normalize(Env.GetEnvironmentVariables(EnvTgt.User), prefix: "e"),
                ConfigHelper.Normalize(Env.GetEnvironmentVariables(EnvTgt.Process), prefix: "e"),
                // Inject application configuration...
                ConfigurationManager.AppSettings,
                // and inject start parameters...
                ConfigHelper.ParseToDict(ref args)
            };

            // Combine all settings into one!
            return(ConfigHelper.ToStringDict(all));
        }
Exemple #3
0
 public IDictionary <string, string> GetEnvironmentVariables(EnvironmentVariableTarget target)
 {
     return(Env.GetEnvironmentVariables(target).ToGenericDictionary <string, string>());
 }
 public static IDictionary GetEnvironmentVariables(EnvironmentVariableTarget?target = null)
 {
     return(target.HasValue ? Env.GetEnvironmentVariables(target.Value) : Env.GetEnvironmentVariables());
 }