コード例 #1
0
ファイル: Settings.cs プロジェクト: wolsk1/ratio
 /// <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));
     }
 }
コード例 #2
0
        /// <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;
        }
コード例 #3
0
 /// <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);
     }
 }
コード例 #4
0
ファイル: WebServiceProvider.cs プロジェクト: wolsk1/ratio
        /// <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);
        }
コード例 #5
0
        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);
        }