/// <summary> /// Copies the provider's data. /// </summary> /// <param name="provider">The provider.</param> private static void CopyProviderData(ISettingsProvider provider) { foreach (string key in provider.Values.AllKeys) { settings.Add(key, provider.Values.Get(key)); } }
/// <summary> /// Override this in child class to implement custom initialization. /// </summary> /// <param name="configurationSection">The section.</param> protected override void MemberwiseInitialize(ConfSection configurationSection) { sectionName = GetSettingsValue(SectionNameAttributeName); if (string.IsNullOrEmpty(this.sectionName)) { throw new InvalidOperationException("Missing parameter \"" + SectionNameAttributeName + "\"."); } var values = ConfigurationManager.GetSection(this.sectionName) as NameValueCollection; if (values == null) { throw new SectionNotFoundException("Section \"" + this.sectionName + "\" is not found."); } SettingsCollection v = new SettingsCollection(); foreach (string key in values.AllKeys) { v.Add(key, values.Get(key)); } Values = v; }
/// <summary> /// Reads the content of the node. /// </summary> /// <param name="hiveKey">The hive key.</param> /// <param name="collection">The collection.</param> private static void ReadNodeContent(RegistryKey hiveKey, ref SettingsCollection collection) { foreach (string key in hiveKey.GetValueNames()) { string value = Convert.ToString(hiveKey.GetValue(key), CultureInfo.InvariantCulture); collection.Add(key, value); } }
/// <summary> /// Make call to a webservice to get all configuration settings. /// </summary> /// <param name="provider">The provider.</param> /// <returns>Get settings collection <see cref="SettingsCollection"/>.</returns> private static SettingsCollection GetSettings(Provider provider) { var settingsData = provider.GetSettings(); // Convert to SettingsCollection var collection = new SettingsCollection(); foreach (var setting in settingsData) { collection.Add(setting.Key, setting.Value); } return(collection); }
public SettingsCollection ReadSettings(XmlNode node) { if (node == null) { throw new ArgumentNullException("node"); } SettingsCollection settings = new SettingsCollection(); XmlNodeList keys = node.ChildNodes; foreach (XmlNode key in keys) { if (key.NodeType != XmlNodeType.Comment) { settings.Add(key.Attributes.GetNamedItem("key").InnerText, key.Attributes.GetNamedItem("value").InnerText); } } return(settings); }