/// <summary> /// Checks whether the result of a call to <see cref="IConfigurationSource.GetSection(string)"/> should be merged.<br/> /// If the call should be merged, performs the merge behavior and returns the resulting <see cref="ConfigurationSection"/> intance.<br/> /// If the call should not be merged returns <paramref name="configurationSection"/>. /// </summary> /// <param name="sectionName">The name of the section that was retrieved from configuration.</param> /// <param name="configurationSection">The section that was retrieved from configuration.</param> /// <returns>The resulting <see cref="ConfigurationSection"/> instance.</returns> /// <seealso cref="IConfigurationSource.GetSection(string)"/> protected override ConfigurationSection DoCheckGetSection(string sectionName, ConfigurationSection configurationSection) { if (string.IsNullOrEmpty(parentSourceName)) { return(configurationSection); } IConfigurationSource parentSource = GetSubordinateSource(parentSourceName); if (parentSource == null) { return(configurationSection); } ConfigurationSection parentSection = parentSource.GetSection(sectionName); if (configurationSection == null) { return(parentSection); } if (parentSection == null) { return(configurationSection); } ConfigurationSection localSection = CloneSection(configurationSection); ConfigurationSectionMerge configurationMerge = new ConfigurationSectionMerge(parentSection, localSection); ConfigurationSection mergedSection = configurationMerge.GetMergedSection(); EnsurePropagatingSectionChangeEvents(parentSourceName, sectionName); return(mergedSection); }
/// <summary> /// Checks whether the result of a call to <see cref="IConfigurationSource.GetSection(string)"/> should be merged.<br/> /// If the call should be merged, performs the merge behavior and returns the resulting <see cref="ConfigurationSection"/> intance.<br/> /// If the call should not be merged returns <paramref name="configurationSection"/>. /// </summary> /// <param name="sectionName">The name of the section that was retrieved from configuration.</param> /// <param name="configurationSection">The section that was retrieved from configuration.</param> /// <returns>The resulting <see cref="ConfigurationSection"/> instance.</returns> /// <seealso cref="IConfigurationSource.GetSection(string)"/> protected override ConfigurationSection DoCheckGetSection(string sectionName, ConfigurationSection configurationSection) { if (string.IsNullOrEmpty(parentSourceName)) { return configurationSection; } IConfigurationSource parentSource = GetSubordinateSource(parentSourceName); if (parentSource == null) { return configurationSection; } ConfigurationSection parentSection = parentSource.GetSection(sectionName); if (configurationSection == null) { return parentSection; } if (parentSection == null) { return configurationSection; } ConfigurationSection localSection = CloneSection(configurationSection); ConfigurationSectionMerge configurationMerge = new ConfigurationSectionMerge(parentSection, localSection); ConfigurationSection mergedSection = configurationMerge.GetMergedSection(); EnsurePropagatingSectionChangeEvents(parentSourceName, sectionName); return mergedSection; }