Esempio n. 1
0
        public void XmlSerialization()
        {
            var serializer = new XMLSerializer();
            var result     = serializer.Serialize(output);

            Assert.AreEqual(result, xmlTestString);
        }
Esempio n. 2
0
        public void XmlDeserialization()
        {
            var serializer = new XMLSerializer();
            var result     = serializer.Deserialize <Output>(xmlTestString);

            Assert.AreEqual(result.SumResult, output.SumResult);
            Assert.AreEqual(result.MulResult, output.MulResult);
            Assert.AreEqual(result.SortedInputs, output.SortedInputs);
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            var input = new Input {
                K = 10, Sums = new decimal[] { 1.01M, 2.02M }, Muls = new int[] { 1, 4 }
            };                                                                                               //разбить str на объект
            ISerializer serializer;
            var         type = Console.ReadLine();

            if (type == "json")
            {
                serializer = new JSONSerializer();
            }
            else
            {
                serializer = new XMLSerializer();
            }

            var str = serializer.Serialize <Input>(input);
            var obj = serializer.Deserialize <Input>(str);

            Console.WriteLine(str);
            Console.WriteLine(obj);
            Console.ReadLine();
        }