Ejemplo n.º 1
0
        public void teste8()
        {
            {
                List <String> l = new List <string>();
                l.Add("thiago");
                l.Add("pastor");
                SerializatorMachine SerializatorMachine = new SerializatorMachine();
                SerializatorMachine.Serialize(l, "teste8.xml", Encoding.Default);
                List <string> ob = SerializatorMachine.Desserialize <List <string> >("teste8.xml");
                System.Diagnostics.Debug.Assert(ob[0] == "thiago");
                System.Diagnostics.Debug.Assert(ob[1] == "pastor");
            }
            {
                List <int> l = new List <int>();
                l.Add(2);
                l.Add(3);
                SerializatorMachine SerializatorMachine = new SerializatorMachine();
                SerializatorMachine.Serialize(l, "teste8.xml", Encoding.Default);
                List <int> ob = SerializatorMachine.Desserialize <List <int> >("teste8.xml");
                System.Diagnostics.Debug.Assert(ob[0] == 2);
                System.Diagnostics.Debug.Assert(ob[1] == 3);
            }

            {
                List <enumteste> l = new List <enumteste>();
                l.Add(enumteste.opt1);
                l.Add(enumteste.opt3);
                SerializatorMachine SerializatorMachine = new SerializatorMachine();
                SerializatorMachine.Serialize(l, "teste8.xml", Encoding.Default);
                List <enumteste> ob = SerializatorMachine.Desserialize <List <enumteste> >("teste8.xml");
                System.Diagnostics.Debug.Assert(ob[0] == enumteste.opt1);
                System.Diagnostics.Debug.Assert(ob[1] == enumteste.opt3);
            }
        }
Ejemplo n.º 2
0
        public void teste5()
        {
            array array = new array();

            array.ar  = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            array.str = new string[] { "asfadsfa", "a" };
            array.en  = new ens[] { ens.a, ens.c };
            array.ss1 = new strc[] { new strc()
                                     {
                                         a = 1
                                     }, new strc()
                                     {
                                         a = 5
                                     } };
            array.ss = new strc2[] { new strc2()
                                     {
                                         a = 1
                                     }, new strc2()
                                     {
                                         a = 5
                                     } };
            SerializatorMachine SerializatorMachine = new SerializatorMachine();

            SerializatorMachine.Serialize(array, "teste5.xml", Encoding.Default);
            array ob = SerializatorMachine.Desserialize <array>("teste5.xml");

            System.Diagnostics.Debug.Assert(ob.ar.Count() == 9);
            System.Diagnostics.Debug.Assert(ob.ar[1] == 2);
            System.Diagnostics.Debug.Assert(ob.str[1] == "a");
            System.Diagnostics.Debug.Assert(ob.en[1] == ens.c);
            System.Diagnostics.Debug.Assert(ob.ss1[1].a == 5);
            System.Diagnostics.Debug.Assert(ob.ss[1].a == 5);
        }
Ejemplo n.º 3
0
 public void teste2()
 {
     teststruct tt = new teststruct();
     tt.t = 10;
     SerializatorMachine SerializatorMachine = new SerializatorMachine();
     SerializatorMachine.Serialize(tt, "teste2.xml", Encoding.Default);
     teststruct ob = (teststruct) SerializatorMachine.Desserialize("teste2.xml");
     System.Diagnostics.Debug.Assert(ob.t== 10);
 }
Ejemplo n.º 4
0
        public void teste2()
        {
            teststruct tt = new teststruct();

            tt.t = 10;
            SerializatorMachine SerializatorMachine = new SerializatorMachine();

            SerializatorMachine.Serialize(tt, "teste2.xml", Encoding.Default);
            teststruct ob = (teststruct)SerializatorMachine.Desserialize("teste2.xml");

            System.Diagnostics.Debug.Assert(ob.t == 10);
        }
Ejemplo n.º 5
0
        public void teste7()
        {
            testeextend2 testeextend2 = new testeextend2();

            testeextend2.t = 4;
            SerializatorMachine SerializatorMachine = new SerializatorMachine();

            SerializatorMachine.Serialize(testeextend2, "teste7.xml", Encoding.Default);
            testeextend2 ob = SerializatorMachine.Desserialize <testeextend2>("teste7.xml");

            System.Diagnostics.Debug.Assert(ob.t2 == 8);
        }
Ejemplo n.º 6
0
 public void teste4()
 {
     partialserialize s = new partialserialize();
     s.ser = 10;
     s.noser = 20;
     SerializatorMachine SerializatorMachine = new SerializatorMachine();
     SerializatorMachine.Serialize(s, "teste4.xml", Encoding.Default);
     partialserialize ob = SerializatorMachine.Desserialize<partialserialize>("teste4.xml");
     System.Diagnostics.Debug.Assert(ob.noser != 20);
     System.Diagnostics.Debug.Assert(ob.noser == 0);
     System.Diagnostics.Debug.Assert(ob.ser == 10);
 }
Ejemplo n.º 7
0
 public void teste1()
 {
     testtypes testtypes = new testeserialization.testtypes();
     SerializatorMachine SerializatorMachine = new SerializatorMachine();
     SerializatorMachine.Serialize(testtypes, "teste1.xml", Encoding.Default);
     testtypes ob = SerializatorMachine.Desserialize<testtypes>("teste1.xml") ;
     System.Diagnostics.Debug.Assert(ob.str == "t1");
     System.Diagnostics.Debug.Assert(ob.fl == 1);
     System.Diagnostics.Debug.Assert(ob.it == 1);
     System.Diagnostics.Debug.Assert(ob.sh == 1);
     System.Diagnostics.Debug.Assert(ob.ln == 1);
     System.Diagnostics.Debug.Assert(ob.dl == 1);
     System.Diagnostics.Debug.Assert(ob.ch == 'a');
 }
Ejemplo n.º 8
0
        public void teste9()
        {
            Dictionary <String, int> l = new Dictionary <string, int>();

            l.Add("abc", 1);
            l.Add("abcdef", 2);
            SerializatorMachine SerializatorMachine = new SerializatorMachine();

            SerializatorMachine.Serialize(l, "teste9.xml", Encoding.Default);
            Dictionary <String, int> ob = SerializatorMachine.Desserialize <Dictionary <String, int> >("teste9.xml");

            System.Diagnostics.Debug.Assert(ob["abc"] == 1);
            System.Diagnostics.Debug.Assert(ob["abcdef"] == 2);
        }
Ejemplo n.º 9
0
        public void teste4()
        {
            partialserialize s = new partialserialize();

            s.ser   = 10;
            s.noser = 20;
            SerializatorMachine SerializatorMachine = new SerializatorMachine();

            SerializatorMachine.Serialize(s, "teste4.xml", Encoding.Default);
            partialserialize ob = SerializatorMachine.Desserialize <partialserialize>("teste4.xml");

            System.Diagnostics.Debug.Assert(ob.noser != 20);
            System.Diagnostics.Debug.Assert(ob.noser == 0);
            System.Diagnostics.Debug.Assert(ob.ser == 10);
        }
Ejemplo n.º 10
0
        public void teste1()
        {
            testtypes           testtypes           = new testeserialization.testtypes();
            SerializatorMachine SerializatorMachine = new SerializatorMachine();

            SerializatorMachine.Serialize(testtypes, "teste1.xml", Encoding.Default);
            testtypes ob = SerializatorMachine.Desserialize <testtypes>("teste1.xml");

            System.Diagnostics.Debug.Assert(ob.str == "t1");
            System.Diagnostics.Debug.Assert(ob.fl == 1);
            System.Diagnostics.Debug.Assert(ob.it == 1);
            System.Diagnostics.Debug.Assert(ob.sh == 1);
            System.Diagnostics.Debug.Assert(ob.ln == 1);
            System.Diagnostics.Debug.Assert(ob.dl == 1);
            System.Diagnostics.Debug.Assert(ob.ch == 'a');
        }
Ejemplo n.º 11
0
        public void teste6()
        {
            extend ex = new extend();

            ex.a     = "teste";
            ex.strc2 = new strc2()
            {
                a = 4
            };
            SerializatorMachine SerializatorMachine = new SerializatorMachine();

            SerializatorMachine.Serialize(ex, "teste6.xml", Encoding.Default);
            extend ob = SerializatorMachine.Desserialize <extend>("teste6.xml");

            System.Diagnostics.Debug.Assert(ob.a == "teste");
            System.Diagnostics.Debug.Assert(ob.strc2.a == 4);
        }
Ejemplo n.º 12
0
        public void teste5()
        {
            array array = new array();
            array.ar = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; 
            array.str = new string[] { "asfadsfa", "a" };
            array.en = new ens[] { ens.a, ens.c };
            array.ss1 = new strc[] { new strc() { a = 1 }, new strc() { a = 5 } };
            array.ss = new strc2[] { new strc2() { a = 1 }, new strc2() { a = 5 } };
            SerializatorMachine SerializatorMachine = new SerializatorMachine();
            SerializatorMachine.Serialize(array, "teste5.xml", Encoding.Default);
            array ob = SerializatorMachine.Desserialize<array>("teste5.xml");
            System.Diagnostics.Debug.Assert(ob.ar.Count() == 9);
            System.Diagnostics.Debug.Assert(ob.ar[1] == 2);
            System.Diagnostics.Debug.Assert(ob.str[1] == "a");
            System.Diagnostics.Debug.Assert(ob.en[1] == ens.c);
            System.Diagnostics.Debug.Assert(ob.ss1[1].a == 5);
            System.Diagnostics.Debug.Assert(ob.ss[1].a == 5);

        }
Ejemplo n.º 13
0
 public void teste3()
 {
     t1 t1 = new t1()
     {
         tt1 = "t1",
         t2 = new t2()
         {
             tt2 = "t2",
             t3 = new t3()
             {
                 tt3 = "t3"
             }
         }
     };
     SerializatorMachine SerializatorMachine = new SerializatorMachine();
     SerializatorMachine.Serialize(t1, "teste3.xml", Encoding.Default);
     t1 ob = SerializatorMachine.Desserialize<t1>("teste3.xml");
     System.Diagnostics.Debug.Assert(ob.tt1 == "t1");
     System.Diagnostics.Debug.Assert(ob.t2.tt2 == "t2");
     System.Diagnostics.Debug.Assert(ob.t2.t3.tt3 == "t3");
 }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            teste intern = new testeserialization.teste()
            {
                fieldString = "testestring",
                propertyInt = 12
            };

            teste teste = new testeserialization.teste()
            {
                fieldString = "internal",
                propertyInt = 13,
                teste2      = intern
            };

            testeenum testeenum = new testeserialization.testeenum()
            {
                enumteste = enumteste.opt2
            };

            //SerializatorMachine.Serialize(intern, "teste.xml");
            SerializatorMachine SerializatorMachine = new SerializatorMachine();

            SerializatorMachine.Serialize(testeenum, "teste.xml", Encoding.Default);
            object ob = SerializatorMachine.Desserialize <testeenum>("teste.xml");

            tests t = new tests();

            t.teste1();
            t.teste2();
            t.teste3();
            t.teste4();
            t.teste5();
            t.teste6();
            t.teste7();
            t.teste8();
            t.teste9();
        }
Ejemplo n.º 15
0
        public void teste3()
        {
            t1 t1 = new t1()
            {
                tt1 = "t1",
                t2  = new t2()
                {
                    tt2 = "t2",
                    t3  = new t3()
                    {
                        tt3 = "t3"
                    }
                }
            };
            SerializatorMachine SerializatorMachine = new SerializatorMachine();

            SerializatorMachine.Serialize(t1, "teste3.xml", Encoding.Default);
            t1 ob = SerializatorMachine.Desserialize <t1>("teste3.xml");

            System.Diagnostics.Debug.Assert(ob.tt1 == "t1");
            System.Diagnostics.Debug.Assert(ob.t2.tt2 == "t2");
            System.Diagnostics.Debug.Assert(ob.t2.t3.tt3 == "t3");
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            teste intern = new testeserialization.teste()
            {
                fieldString = "testestring",
                propertyInt = 12
            };

            teste teste = new testeserialization.teste()
            {
                fieldString = "internal",
                propertyInt = 13,
                teste2 = intern
            };

            testeenum testeenum = new testeserialization.testeenum()
            {
                enumteste = enumteste.opt2
            };

            //SerializatorMachine.Serialize(intern, "teste.xml");
            SerializatorMachine SerializatorMachine = new SerializatorMachine();
            SerializatorMachine.Serialize(testeenum, "teste.xml", Encoding.Default);
            object ob = SerializatorMachine.Desserialize<testeenum>("teste.xml");

            tests t = new tests();
            t.teste1();
            t.teste2();
            t.teste3();
            t.teste4();
            t.teste5();
            t.teste6();
            t.teste7();
            t.teste8();
            t.teste9();

        }
Ejemplo n.º 17
0
        public void teste8()
        {
            {
                List<String> l = new List<string>();
                l.Add("thiago");
                l.Add("pastor");
                SerializatorMachine SerializatorMachine = new SerializatorMachine();
                SerializatorMachine.Serialize(l, "teste8.xml", Encoding.Default);
                List<string> ob = SerializatorMachine.Desserialize<List<string>>("teste8.xml");
                System.Diagnostics.Debug.Assert(ob[0] == "thiago");
                System.Diagnostics.Debug.Assert(ob[1] == "pastor");
            }
            {
                List<int> l = new List<int>();
                l.Add(2);
                l.Add(3);
                SerializatorMachine SerializatorMachine = new SerializatorMachine();
                SerializatorMachine.Serialize(l, "teste8.xml", Encoding.Default);
                List<int> ob = SerializatorMachine.Desserialize<List<int>>("teste8.xml");
                System.Diagnostics.Debug.Assert(ob[0] == 2);
                System.Diagnostics.Debug.Assert(ob[1] == 3);
            }

            {
                List<enumteste> l = new List<enumteste>();
                l.Add(enumteste.opt1);
                l.Add(enumteste.opt3);
                SerializatorMachine SerializatorMachine = new SerializatorMachine();
                SerializatorMachine.Serialize(l, "teste8.xml", Encoding.Default);
                List<enumteste> ob = SerializatorMachine.Desserialize<List<enumteste>>("teste8.xml");
                System.Diagnostics.Debug.Assert(ob[0] == enumteste.opt1);
                System.Diagnostics.Debug.Assert(ob[1] == enumteste.opt3);
            }
        }
Ejemplo n.º 18
0
 public void teste7()
 {
     testeextend2 testeextend2 = new testeextend2();
     testeextend2.t = 4;
     SerializatorMachine SerializatorMachine = new SerializatorMachine();
     SerializatorMachine.Serialize(testeextend2, "teste7.xml", Encoding.Default);
     testeextend2 ob = SerializatorMachine.Desserialize<testeextend2>("teste7.xml");
     System.Diagnostics.Debug.Assert(ob.t2 == 8);
 }
Ejemplo n.º 19
0
        public T Desserialize <T>(String path, object context = null)
        {
            SerializatorMachine SerializatorMachine = new SerializatorMachine();

            return((T)SerializatorMachine.Desserialize(path, context, desserializador));
        }
Ejemplo n.º 20
0
        public void Serialize(Object obj, String path)
        {
            SerializatorMachine SerializatorMachine = new SerializatorMachine();

            SerializatorMachine.Serialize(obj, path, Encoding.Default, serializator);
        }
Ejemplo n.º 21
0
 public void teste6()
 {
     extend ex = new extend();
     ex.a = "teste";
     ex.strc2 = new strc2() { a = 4 };
     SerializatorMachine SerializatorMachine = new SerializatorMachine();
     SerializatorMachine.Serialize(ex, "teste6.xml", Encoding.Default);
     extend ob = SerializatorMachine.Desserialize<extend>("teste6.xml");
     System.Diagnostics.Debug.Assert(ob.a== "teste");
     System.Diagnostics.Debug.Assert(ob.strc2.a == 4);
 }
Ejemplo n.º 22
0
 public void teste9()
 {
     Dictionary<String,int> l = new Dictionary<string,int>();
     l.Add("abc",1);
     l.Add("abcdef", 2);
     SerializatorMachine SerializatorMachine = new SerializatorMachine();
     SerializatorMachine.Serialize(l, "teste9.xml", Encoding.Default);
     Dictionary<String, int> ob = SerializatorMachine.Desserialize<Dictionary<String, int>>("teste9.xml");
     System.Diagnostics.Debug.Assert(ob["abc"] == 1);
     System.Diagnostics.Debug.Assert(ob["abcdef"] == 2);
 }