/// <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; } } }