fixup-config2.cs 749 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Xml;
  3. public class FixupXml
  4. {
  5. public static void Main (string [] args)
  6. {
  7. if (args.Length == 0) {
  8. Console.WriteLine ("pass path-to-web.config.");
  9. return;
  10. }
  11. XmlDocument doc = new XmlDocument ();
  12. doc.Load (args [0]);
  13. XmlElement el = doc.SelectSingleNode ("/configuration/system.web/httpHandlers") as XmlElement;
  14. XmlElement old = el.SelectSingleNode ("add[@path='*.svc']") as XmlElement;
  15. XmlNode up = doc.ReadNode (new XmlTextReader ("fixup-config2.xml"));
  16. if (old != null)
  17. el.RemoveChild (old);
  18. el.InsertAfter (up, null);
  19. XmlTextWriter w = new XmlTextWriter (args [0], null);
  20. w.Formatting = Formatting.Indented;
  21. w.IndentChar = '\t';
  22. w.Indentation = 1;
  23. doc.Save (w);
  24. w.Close ();
  25. }
  26. }