/// <summary>
 /// Merge with config source specified.
 /// </summary>
 /// <param name="source"></param>
 /// <param name="dest"></param>
 protected virtual void Merge(IConfigSection source, IConfigSection dest)
 {
     // Get all the sections.
     foreach (DictionaryEntry entry in source)
     {
         // Create new config section.
         if (entry.Value is IConfigSection)
         {
             IConfigSection newDest = null;
             if (dest.Contains(entry.Key))
             {
                 newDest = dest.GetSection(entry.Key.ToString());
             }
             else
             {
                 newDest = new ConfigSection(entry.Key.ToString());
                 dest.Add(newDest.Name, newDest);
             }
             Merge(entry.Value as IConfigSection, newDest);
         }
         else // Just overwrite the keys.
         {
             dest[entry.Key] = entry.Value;
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Checks whether or not the key exists in the section.
        /// </summary>
        /// <param name="section"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public bool Contains(string section, string key)
        {
            IConfigSection configSection = GetSection(section);

            if (configSection == null)
            {
                return(false);
            }

            return(configSection.Contains(key));
        }