Example #1
0
 /// <summary>
 /// Reads all keys in the appSettings section of the default configuration
 /// file and adds them all as valid arguments so that they may be
 /// specified on the command line.
 /// </summary>
 protected static void AddConfigurationSwitches()
 {
     DefaultConfiguration.GetAppSettings().AllKeys.Each(key =>
     {
         AddValidArgument(key, $"Override value from config: {DefaultConfiguration.GetAppSetting(key)}");
     });
 }
        /// <summary>
        /// Adds the settings from the current ApplicationConfiguration instance
        /// to the DefaultConfiguration
        /// </summary>
        public void Inject()
        {
            NameValueCollection         appSettings = DefaultConfiguration.GetAppSettings();
            Dictionary <string, string> settings    = ToDictionary();

            foreach (string key in appSettings.AllKeys)
            {
                settings.AddMissing(key, appSettings[key]);
            }
            DefaultConfiguration.SetAppSettings(settings);
        }
Example #3
0
        protected void SaveDefaultConfiguration()
        {
            string appNameKey = "ApplicationName";
            NameValueCollection defaultConfig = DefaultConfiguration.GetAppSettings();
            string appName = DefaultConfiguration.GetAppSetting(appNameKey, "UNKNOWN");
            Dictionary <string, string> settings = new Dictionary <string, string>();

            foreach (string key in defaultConfig.AllKeys)
            {
                if (!key.Equals(appNameKey))
                {
                    settings.Add(key, defaultConfig[key]);
                }
            }
            SetApplicationConfiguration(appName, settings, "Default");
        }
Example #4
0
        private void SetAppSettings()
        {
            _preInjectAppSettings = DefaultConfiguration.GetAppSettings();
            NameValueCollection appSettings = new NameValueCollection();

            // copy the original values
            foreach (string key in _preInjectAppSettings.AllKeys)
            {
                appSettings[key] = _preInjectAppSettings[key];
            }
            // --

            // override with values from "this"
            foreach (string key in AppSettings.Keys)
            {
                appSettings[key] = AppSettings[key];
            }
            DefaultConfiguration.SetAppSettings(appSettings);
        }