private static IEnumerable <ConfigurationSectionEntry> GetConfigurationSections(ConfigurationSectionGroup group, ConfigurationSectionGroupPath groupPath, ConfigurationSectionErrorHandler errorHandler, bool recursive) { if (recursive) { foreach (ConfigurationSectionGroup childGroup in group.SectionGroups) { foreach (var sectionEntry in GetConfigurationSections(childGroup, groupPath.GetChildGroupPath(childGroup.Name), errorHandler, true)) { yield return(sectionEntry); } } } for (var n = 0; n < group.Sections.Count; ++n) { ConfigurationSection section = null; try { section = group.Sections[n]; } catch (ConfigurationErrorsException) { if (errorHandler != null) { section = errorHandler.Invoke(groupPath, group.Sections.Keys[n]); } } if (section != null) { yield return(new ConfigurationSectionEntry(groupPath, section)); } } }
private static IEnumerable<ConfigurationSectionEntry> GetConfigurationSections(ConfigurationSectionGroup group, ConfigurationSectionGroupPath groupPath, ConfigurationSectionErrorHandler errorHandler, bool recursive) { if (recursive) { foreach (ConfigurationSectionGroup childGroup in group.SectionGroups) { foreach (var sectionEntry in GetConfigurationSections(childGroup, groupPath.GetChildGroupPath(childGroup.Name), errorHandler, true)) yield return sectionEntry; } } for (var n = 0; n < group.Sections.Count; ++n) { ConfigurationSection section = null; try { section = group.Sections[n]; } catch (ConfigurationErrorsException) { if (errorHandler != null) section = errorHandler.Invoke(groupPath, group.Sections.Keys[n]); } if (section != null) yield return new ConfigurationSectionEntry(groupPath, section); } }