Apprenda.Log4NetConnectorPolicy.Log4NetAppConfigUpdateService.AddIgnoredConfigSection C# (CSharp) Method

AddIgnoredConfigSection() private method

Analyze the configuration file and add the log4net config section declaration before injecting a log4net configuration section, if needed.
private AddIgnoredConfigSection ( ) : void
return void
        private void AddIgnoredConfigSection()
        {
            if (_messages.Any())
            {
                _messages.Add("Skipping configuration section update due to previous messages.");
                return;
            }

            _configurationNode = _document.Element("configuration");
            if (_configurationNode == null)
            {
                _messages.Add(
                    "No <configuration> element was found, which is required for Web.config and app.config. Something drastic seems to be wrong with the workload.");
                return;
            }

            var configurationSectionsElement = _document.XPathSelectElement("//configuration/configSections");
            if (configurationSectionsElement == null)
            {
                configurationSectionsElement = new XElement("configSections");
                _configurationNode.Add(configurationSectionsElement);
            }

            var logSectionConfigElement = configurationSectionsElement.XPathSelectElement("//section[@name='log4net']");
            if (logSectionConfigElement == null)
            {
                configurationSectionsElement.Add(
                    new XElement(
                        "section",
                        new XAttribute("name", "log4net"),
                        new XAttribute("type", "System.Configuration.IgnoreSectionHandler")));
            }
        }