public object GetSection(string configKey) { if (configKey == "appSettings") { if (_appSettings != null) return _appSettings; } else if (configKey == "connectionStrings") { if (_connectionStrings != null) return _connectionStrings; } // get the section from the default location (web.config or app.config) object section = _clientConfigSystem.GetSection(configKey); switch (configKey) { case "appSettings": if (section is NameValueCollection) { // create a new collection because the underlying collection is read-only var cfg = new NameValueCollection((NameValueCollection)section); _appSettings = cfg; // merge the settings from core with the local appsettings _appSettings = cfg.Merge(System.Configuration.ConfigurationManager.AppSettings); section = _appSettings; } break; case "connectionStrings": // Cannot simply return our ConnectionStringSettingsCollection as the calling routine expects a ConnectionStringsSection result ConnectionStringsSection connectionStringsSection = new ConnectionStringsSection(); _connectionStrings = connectionStringsSection; // create a new collection because the underlying collection is read-only var cssc = new ConnectionStringSettingsCollection(); // copy the existing connection strings into the new collection foreach (ConnectionStringSettings connectionStringSetting in ((ConnectionStringsSection)section).ConnectionStrings) { cssc.Add(connectionStringSetting); } //// merge the settings from core with the local connectionStrings cssc = cssc.Merge(System.Configuration.ConfigurationManager.ConnectionStrings); // Add our merged connection strings to the new ConnectionStringsSection foreach (ConnectionStringSettings connectionStringSetting in cssc) { connectionStringsSection.ConnectionStrings.Add(connectionStringSetting); } _connectionStrings = connectionStringsSection; section = _connectionStrings; break; } return section; }