Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- XDocument machineConfig = XDocument.Load(string.Format(@"{0}\config\machine.config", dotnet));
- Dictionary<string, string> sectionAttributes = new Dictionary<string, string>();
- sectionAttributes["name"] = "system.webServer";
- sectionAttributes["type"] = "System.Configuration.IgnoreSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken= PublicKeyToken=b77a5c561934e089";
- if (!machineConfig.Descendants(XName.Get("section"))
- .Any((XElement element) =>
- {
- return sectionAttributes.Keys.All((string key) =>
- element.Attribute(XName.Get(key)).Value == sectionAttributes[key]);
- //List<string> keys = sectionAttributes.Keys.ToList<string>();
- //return element.Attributes().Aggregate<XAttribute, int>(0, (int count, XAttribute attrib) =>
- // {
- // if (keys.Contains(attrib.Name.NamespaceName) && attrib.Value == sectionAttributes[attrib.Name.NamespaceName])
- // {
- // ++count;
- // keys.Remove(attrib.Name.NamespaceName);
- // }
- // return count;
- // }) == keys.Count;
- }));
- {
- XElement configSections = machineConfig.Descendants(XName.Get("configSections")).First();
- //<section name="system.webServer" type="System.Configuration.IgnoreSectionHandler,
- //System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
- XElement section = new XElement(XName.Get("section"),
- new XAttribute(XName.Get("name"), sectionAttributes["name"]),
- new XAttribute(XName.Get("type"), sectionAttributes["type"]));
- configSections.Add(section);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement