Add() public method

public Add ( KeyValueConfigurationElement keyValue ) : void
keyValue KeyValueConfigurationElement
return void
コード例 #1
0
        private static KeyValueConfigurationCollection GetKeyValueCollection()
        {
            var collection = new KeyValueConfigurationCollection();
            collection.Add("Name", "Value");
            collection.Add("Email", "*****@*****.**");
            collection.Add("Company", "IBM");
            collection.Add("Year", "2011");

            return collection;
        }
コード例 #2
0
 protected override void AddAppConfigSpecificItems(KeyValueConfigurationCollection kvcc)
 {
     // NOTE: insert a valid connection string to a SqlServer 2008 db
     try
     {
         if (kvcc["SqlServer2008ConnectionString"] == null) 
             kvcc.Add("SqlServer2008ConnectionString", "Data Source=localhost\\SQLEXPRESS;Database=NTSTests;Integrated Security=SSPI;");
     }
     catch
     {
         kvcc.Add("SqlServer2008ConnectionString", "Data Source=localhost\\SQLEXPRESS;Database=NTSTests;Integrated Security=SSPI;");
     }
 }
コード例 #3
0
        public void Should_map_features()
        {
            var settings = new KeyValueConfigurationCollection();
            settings.Add(new KeyValueConfigurationElement("Feature", "true"));
            settings.Add(new KeyValueConfigurationElement("Feature1", "false"));
            var mapper = new KeyValueFeatureMapper();

            var feature = mapper.Map(settings).ToList();

            feature.Count.ShouldBe(2);

            feature[0].Name.ShouldBe("Feature");
            feature[0].State.ShouldBe(true);
        }
コード例 #4
0
ファイル: DictionaryUtils.cs プロジェクト: tukzer/Seif
        public static KeyValueConfigurationCollection ToConfig(
            IDictionary<string, string> dictionary)
        {
            KeyValueConfigurationCollection keyValueConfigurationCollection = new KeyValueConfigurationCollection();

            foreach (var item in dictionary)
            {
                keyValueConfigurationCollection.Add(item.Key, item.Value);
            }
            return keyValueConfigurationCollection;
        }
コード例 #5
0
ファイル: FDUserSettings.cs プロジェクト: fardog/snowpack
        public FDUserSettings()
        {
            localConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
            settings = localConfig.AppSettings.Settings;
            RestoresEnabled = false;

            if(settings["DataStoreFile"] != null)
                DataStoreFile = settings["DataStoreFile"].Value;
            else {
                settings.Add ("DataStoreFile", "index.sqlite");
                DataStoreFile = settings["DataStoreFile"].Value;
            }

            if (localConfig.AppSettings.Settings["DataStorePath"] != null)
                DataStorePath = settings["DataStorePath"].Value;
            else {
                settings.Add ("DataStorePath", System.IO.Path.GetDirectoryName(localConfig.FilePath));
                DataStorePath = settings["DataStorePath"].Value;
            }

            if(settings["AWSAccessKey"] != null)
                AWSAccessKey = settings["AWSAccessKey"].Value;
            else {
                settings.Add ("AWSAccessKey", "");
                AWSAccessKey = settings["AWSAccessKey"].Value;
            }

            if(settings["AWSSecretKey"] != null)
                AWSSecretKey = settings["AWSSecretKey"].Value;
            else {
                settings.Add ("AWSSecretKey", "");
                AWSSecretKey = settings["AWSSecretKey"].Value;
            }

            string AWSRegionTemp;
            if(settings["AWSRegion"] != null)
                    AWSRegionTemp = settings["AWSRegion"].Value;
            else {
                settings.Add ("AWSRegion", "");
                AWSRegionTemp = settings["AWSRegion"].Value;
            }

            if(!String.IsNullOrWhiteSpace(AWSRegionTemp)) AWSRegion = int.Parse(AWSRegionTemp);
            else AWSRegion = 0;

            if(settings["AWSGlacierVaultName"] != null)
                AWSGlacierVaultName = settings["AWSGlacierVaultName"].Value;
            else {
                settings.Add ("AWSGlacierVaultName", "");
                AWSGlacierVaultName = settings["AWSGlacierVaultName"].Value;
            }

            CurrentDataStore = DataStorePath + System.IO.Path.DirectorySeparatorChar + DataStoreFile;

            localConfig.Save (ConfigurationSaveMode.Modified);
        }
コード例 #6
0
        /// <summary>
        /// Returns merged settings collection
        /// </summary>
        private KeyValueConfigurationCollection Merge(List<String> paths)
        {
            var mergedSettings = new KeyValueConfigurationCollection();

            foreach (var path in paths)
            {
                var settings = GetApplicationSettingsFromDirectory(path);

                if (settings == null)
                    continue;

                foreach (var key in settings.AllKeys)
                {
                    var value = settings[key].Value;

                    mergedSettings.Remove(key);
                    mergedSettings.Add(key, value);
                }                
            }

            return mergedSettings;
        }
コード例 #7
0
 private static void replaceSetting(KeyValueConfigurationCollection appSettings, string key, string value)
 {
     appSettings.Remove(key);
     appSettings.Add(key, value);
 }
        protected override ConfigurationSection Arrange_GetLocalSourceSection()
        {
            KeyValueConfigurationCollection localSettings = new KeyValueConfigurationCollection();
            localSettings.Add(new KeyValueConfigurationElement("key1", "overwrite"));
            localSettings.Add(new KeyValueConfigurationElement("key3", "connstr3"));
            localSettings.EmitClear = true;

            return new DummySectionWithCollections
            {
                AppSettingsLikeCollection = localSettings
            };
        }
        protected override ConfigurationSection Arrange_GetParentSourceSection()
        {
            KeyValueConfigurationCollection parentSettings = new KeyValueConfigurationCollection();
            parentSettings.Add(new KeyValueConfigurationElement("key1", "value1"));
            parentSettings.Add(new KeyValueConfigurationElement("key2", "value2"));

            return new DummySectionWithCollections
            {
                AppSettingsLikeCollection = parentSettings
            };
        }
コード例 #10
0
 private static KeyValueConfigurationCollection Convert(NameValueCollection collection)
 {
     var settings = new KeyValueConfigurationCollection();
     foreach (var key in collection.AllKeys)
     {
         settings.Add(key, ConfigurationManager.AppSettings[key]);
     }
     return settings;
 }
コード例 #11
0
 public void Test()
 {
     KeyValueConfigurationCollection collection = new KeyValueConfigurationCollection();
     collection.Add("key", "value");
 }
コード例 #12
0
ファイル: SettingsModel.cs プロジェクト: ezsoftware/Babylon
 private void updateKV(KeyValueConfigurationCollection kv, string key_name, string value_string)
 {
     kv.Remove(key_name);
     kv.Add(key_name, value_string);
 }
コード例 #13
0
 protected override void AddAppConfigSpecificItems(KeyValueConfigurationCollection kvcc)
 {
     // NOTE: insert a valid connection string to a postgis db
     if (kvcc["PostGisConnectionString"] == null)
         kvcc.Add("PostGisConnectionString", "Server=ivv-sqlt3.ivv-aachen.de;Port=5432;Database=obe;Integrated Security=SSPI;");            
 }