コード例 #1
0
ファイル: XmlFormatter.cs プロジェクト: zjn0206a/ShipGirlBot
            /// <summary>
            /// Formats the token sequence to the writer
            /// </summary>
            /// <param name="writer"></param>
            /// <param name="tokens"></param>
            public void Format(IEnumerable <Token <MarkupTokenType> > tokens, TextWriter writer)
            {
                if (writer == null)
                {
                    throw new ArgumentNullException("writer");
                }

                XmlWriterAdapter adapter = writer as XmlWriterAdapter;

                if (adapter != null)
                {
                    this.Format(adapter.Writer, tokens);
                    return;
                }

                using (System.Xml.XmlWriter xmlWriter = System.Xml.XmlWriter.Create(
                           writer,
                           new XmlWriterSettings
                {
                    CheckCharacters = false,
                    ConformanceLevel = System.Xml.ConformanceLevel.Auto,
                    Encoding = Encoding.UTF8,
                    Indent = this.Settings.PrettyPrint,
                    IndentChars = this.Settings.Tab,
                    NewLineChars = this.Settings.NewLine,
                    NewLineHandling = System.Xml.NewLineHandling.None,
                    OmitXmlDeclaration = true
                }))
                {
                    this.Format(xmlWriter, tokens);
                }
            }
コード例 #2
0
 internal override void BeginWrite(Stream input) =>
 writer = new XmlWriterAdapter(input);