public void TestMultiObject()
        {
            ObjectSerializerFactory factory = ObjectSerializerFactory.GetInstance();
            StringWriter            sw      = new StringWriter();
            XmlObjectSerializer     ser     = factory.NewXmlSerializer(sw, true, true);

            ser.WriteObject("foo");
            ser.WriteObject("bar");
            ser.Close(true);
            String xml = sw.ToString();

            Console.WriteLine(xml);
            IList <Object> results = new List <Object>();

            factory.DeserializeXmlStream(new StringReader(xml),
                                         o =>
            {
                results.Add(o);
                return(true);
            },
                                         true);
            Assert.AreEqual(2, results.Count);
            Assert.AreEqual("foo", results[0]);
            Assert.AreEqual("bar", results[1]);
        }
예제 #2
0
        private void Init(TcpClient socket, Stream stream)
        {
            _socket = socket;
            _stream = stream;
            ObjectSerializerFactory fact =
                ObjectSerializerFactory.GetInstance();

            _encoder = fact.NewBinarySerializer(_stream);
            _decoder = fact.NewBinaryDeserializer(_stream);
        }