Exemplo n.º 1
0
        public void NoSurrogateSample()
        {
            var tester = new SoapFormatterTester <F>(
                new SoapFormatter(), true);
            var f1 = new F()
            {
                PropertyA = "AAAAA"
            };
            var f2 = tester.SerializeAndDeserialize(f1);

            Console.WriteLine(f1.PropertyA);
            Console.WriteLine(f2.PropertyA);
        }
Exemplo n.º 2
0
        public void SurrogateSample()
        {
            var selector = new SurrogateSelector();

            selector.AddSurrogate(
                typeof(F),
                new StreamingContext(StreamingContextStates.Persistence, null),
                new SerializationSurrogate());

            var tester = new SoapFormatterTester <F>(
                new SoapFormatter(selector, new StreamingContext()), true);
            var f1 = new F()
            {
                PropertyA = "AAAAA"
            };
            var f2 =
                tester.SerializeAndDeserialize(
                    tester.SerializeAndDeserialize(
                        tester.SerializeAndDeserialize(f1)));

            Console.WriteLine(f1.SerializationCounter);
            Console.WriteLine(f2.SerializationCounter);
        }
        public void ISerializationSurrogate()
        {
            var orderDetails = dbContext.Order_Details.Include(x => x.Product).ToArray();

            var selector = new SurrogateSelector();

            selector.AddSurrogate(
                typeof(Order_Detail),
                new StreamingContext(StreamingContextStates.Persistence, null),
                new SerializationSurrogate());

            var tester =
                new SoapFormatterTester<IEnumerable<Order_Detail>>(new SoapFormatter(selector, new StreamingContext()),
                    true);

            tester.SerializeAndDeserialize(orderDetails);
        }