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")));
}
}