//</Snippet4> //<Snippet5> static void GetEnumerator() { try { System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration( ConfigurationUserLevel.None); ConfigurationSectionCollection sections = config.Sections; IEnumerator secEnum = sections.GetEnumerator(); //<Snippet6> int i = 0; while (secEnum.MoveNext()) { string setionName = sections.GetKey(i); Console.WriteLine( "Section name: {0}", setionName); i += 1; } //</Snippet6> } catch (ConfigurationErrorsException err) { Console.WriteLine(err.ToString()); } }
private IEnumerable ParserProcessing(object config) { object[] sectionKeys = null; if (config == null) { throw new ArgumentNullException(nameof(config)); } if (!(config is Configuration reducedConfig)) { return(null); } ConfigurationSectionCollection sections = reducedConfig.Sections; sectionKeys = new object[sections.Count]; if (sections.Count <= 0) { return(null); } for (var i = 0; i < sections.Count; i++) { var sectionKey = sections.GetKey(i); sectionKeys[i] = sectionKey; Logger.LogInformation($"{sectionKey} был добавлен"); } return(sectionKeys); }