예제 #1
0
        private static JsonReader EncodeObject(string xml)
        {
            JsonRecorder writer = new JsonRecorder();

            JsonMLCodec.EncodeObjectForm(new XmlTextReader(new StringReader(xml)), writer);
            return(writer.CreatePlayer());
        }
예제 #2
0
        public void DecodeObjectAllowsEmptyRootElementAsLongAsXmlWriterIsStarted()
        {
            StringWriter  sw     = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(sw);

            writer.WriteStartElement("root");
            JsonMLCodec.Decode(new JsonTextReader(new StringReader("{}")), writer);
        }
예제 #3
0
        public void EncodeObjectExpectsXmlReaderOnElement()
        {
            XmlTextReader reader = new XmlTextReader(new StringReader("<e>text</e>"));

            reader.Read();
            reader.Read();
            JsonMLCodec.EncodeObjectForm(reader, new JsonRecorder());
        }
예제 #4
0
        private static string DecodeObject(string json)
        {
            StringWriter  sw     = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(sw);

            writer.QuoteChar = '\'';
            JsonMLCodec.DecodeObjectForm(new JsonTextReader(new StringReader(json)), writer);
            return(sw.ToString());
        }
예제 #5
0
 public void DecodeDoesNotAcceptNullXmlWriter()
 {
     JsonMLCodec.Decode(new JsonRecorder().CreatePlayer(), null);
 }
예제 #6
0
 public void DecodeDoesNotAcceptNullJsonReader()
 {
     JsonMLCodec.Decode(null, new XmlTextWriter(new StringWriter()));
 }
예제 #7
0
 public void EncodeDoesNotAcceptNullJsonWriter()
 {
     JsonMLCodec.Encode(new XmlTextReader("http://www.example.com/"), null);
 }
예제 #8
0
 public void EncodeDoesNotAcceptNullXmlReader()
 {
     JsonMLCodec.Encode(null, new JsonRecorder());
 }