public static void SaveFormatted (AddinDescription adesc) { XmlDocument doc = adesc.SaveToXml (); XmlFormatter formatter = new XmlFormatter (); TextStylePolicy textPolicy = new TextStylePolicy (80, 4, false, false, true, EolMarker.Unix); XmlFormattingPolicy xmlPolicy = new XmlFormattingPolicy (); XmlFormatingSettings f = new XmlFormatingSettings (); f.ScopeXPath.Add ("*/*"); f.EmptyLinesBeforeStart = 1; f.EmptyLinesAfterEnd = 1; xmlPolicy.Formats.Add (f); f = new XmlFormatingSettings (); f.ScopeXPath.Add ("Addin"); f.AttributesInNewLine = true; f.AlignAttributes = true; f.AttributesInNewLine = false; xmlPolicy.Formats.Add (f); string xml = formatter.FormatXml (textPolicy, xmlPolicy, doc.OuterXml); File.WriteAllText (adesc.FileName, xml); }
public static string SaveFormattedXml (PolicyContainer policies, AddinDescription adesc) { XmlDocument doc = adesc.SaveToXml (); TextStylePolicy textPolicy = policies.Get<TextStylePolicy> (DesktopService.GetMimeTypeInheritanceChain ("application/x-addin+xml")); XmlFormattingPolicy xmlPolicy = policies.Get<XmlFormattingPolicy> (DesktopService.GetMimeTypeInheritanceChain ("application/x-addin+xml")); return XmlFormatter.FormatXml (textPolicy, xmlPolicy, doc.OuterXml); }