public virtual string Format(IXmlFormat format, string xml) { if (format == null) { throw new ArgumentNullException(nameof(format)); } var root = this.Parser.Parse(xml); var xmlDelaration = this.GetXmlDeclaration(root); var encoding = this.GetEncoding(xmlDelaration); var attributeComparer = this.AttributeComparerFactory.Create(format.AttributeFormat); this.SortAttributesRecursive(attributeComparer, root); var elementComparer = this.ElementComparerFactory.Create(format.ElementFormat); this.SortElementsRecursive(elementComparer, root); string formattedXml; using (var stream = new MemoryStream()) { using (var xmlWriter = XmlWriter.Create(stream, this.CreateXmlWriterSettings(encoding, format, xmlDelaration == null))) { xmlWriter.WriteNode(root.CreateNavigator(), true); } var bytes = stream.ToArray().Skip(encoding.GetPreamble().Length).ToArray(); formattedXml = encoding.GetString(bytes); } return(formattedXml); }
public WxmjCommandFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public JingXieFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public MenJinShouQuanFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public LvYeFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public DuanXinFaSongFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public MenJinErQiFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public HouseAndUserCardFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public QiangZhiGuanKongFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public WxmjAuthorizeCommandFactory(IXmlFormat xmlFormat) { // TODO: Complete member initialization this.xmlFormat = xmlFormat; }
protected internal virtual XmlWriterSettings CreateXmlWriterSettings(Encoding encoding, IXmlFormat format, bool omitXmlDeclaration) { if (encoding == null) { throw new ArgumentNullException(nameof(encoding)); } if (format == null) { throw new ArgumentNullException(nameof(format)); } return(new XmlWriterSettings { Encoding = encoding, Indent = format.Indent, IndentChars = format.IndentString, NewLineChars = format.NewLineString, OmitXmlDeclaration = omitXmlDeclaration }); }
public QykqCommandFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public QiYeFangHuFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public ChuZuWuAnFangFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public SocialAppTerminalFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public YiKaGuanChuanFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public AgreementFormatFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }
public DengJiJiFactory(IXmlFormat xmlFormat) { this.xmlFormat = xmlFormat; }