コード例 #1
0
        internal void EncodeNormalValue(XmlStandard standard)
        {
            FastXmlWriter writer = new FastXmlWriter(50, standard);

            writer.WriteElement("Test", "Value");

            Assert.Equal("<Test>Value</Test>", writer.ToString());
        }
コード例 #2
0
        internal void EncodeSyntaxCharacters(XmlStandard standard)
        {
            FastXmlWriter writer = new FastXmlWriter(50, standard);

            writer.WriteElement("Test", "<&>");

            Assert.Equal("<Test>&lt;&amp;&gt;</Test>", writer.ToString());
        }
コード例 #3
0
        internal void EncodeSurrogatePair(XmlStandard standard)
        {
            FastXmlWriter writer = new FastXmlWriter(50, standard);

            writer.WriteElement("Test", "💩");

            string actual = writer.ToString();

            Assert.Equal("<Test>💩</Test>", actual);
        }
コード例 #4
0
        internal void XDocumentCompatibility(XmlStandard standard)
        {
            FastXmlWriter writer = new FastXmlWriter(ushort.MaxValue + 200, standard, XmlCharMode.Omit, XmlCharMode.Omit);
            StringBuilder sb     = new StringBuilder(ushort.MaxValue);

            for (int i = 0; i < ushort.MaxValue; i++)
            {
                sb.Append((char)i);
            }

            writer.WriteElement("test", sb.ToString());

            XDocument _ = XDocument.Parse(writer.ToString());
        }
コード例 #5
0
        public string FastXmlWriterTest()
        {
            FastXmlWriter writer = new FastXmlWriter(100);

            writer.WriteStartElement("rootnode");
            writer.WriteStartElement("person");

            writer.WriteElement("name", "santa claus");
            writer.WriteElement("age", "800");
            writer.WriteElement("status", "missing");

            writer.WriteElement("name", "Donald 💩💩💩💩💩\0\0\0\0");
            writer.WriteElement("age", "7");
            writer.WriteElement("status", "present");

            writer.WriteEndElement("person");
            writer.WriteEndElement("rootnode");

            return(writer.ToString());
        }