Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            MobileOperator.Deserialization(SerializationType.Xml);
            MobileAccount account1 = new MobileAccount("0668348842");
            MobileAccount account2 = new MobileAccount("0637543684");

            account1.Call(account2);

            account2.SendSms(account1, "message");
            MobileOperator.Serialization(SerializationType.Binary);
            MobileOperator.Serialization(SerializationType.Json);
            MobileOperator.Serialization(SerializationType.Xml);
            MobileOperator.Deserialization(SerializationType.Xml);
            MobileOperator.Deserialization(SerializationType.Json);
            MobileOperator.Deserialization(SerializationType.Binary);


            Console.ReadKey();
        }
Ejemplo n.º 2
0
 public MobileAccount(string phoneNumber)
 {
     PhoneNumber = phoneNumber;
     Money       = MobileOperator.GetBalance(this);
 }
Ejemplo n.º 3
0
 public void SendSms(IMobileAccount account, string message)
 {
     MobileOperator.SendSms(this, account, message);
 }
Ejemplo n.º 4
0
 public void Call(IMobileAccount account)
 {
     MobileOperator.Connect(this, (MobileAccount)account);
 }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Stopwatch     stopWatch = new Stopwatch();
            MobileAccount account1  = new MobileAccount("0668348842");
            MobileAccount account2  = new MobileAccount("0637543684");

            account1.Call(account2);
            account2.SendSms(account1, "message");

            stopWatch.Start();
            for (int i = 0; i < 100; i++)
            {
                MobileOperator.Serialization(SerializationType.Binary);
            }
            stopWatch.Stop();
            Console.WriteLine("Serialization type binary {0} ms", stopWatch.ElapsedMilliseconds);
            Console.WriteLine("Serialization type binary {0} ms", stopWatch.Elapsed);
            stopWatch.Reset();

            stopWatch.Start();
            for (int i = 0; i < 100; i++)
            {
                MobileOperator.Deserialization(SerializationType.Binary);
            }
            stopWatch.Stop();
            Console.WriteLine("Deserialization type binary {0} ms", stopWatch.ElapsedMilliseconds);
            Console.WriteLine("Deserialization type binary {0} ms", stopWatch.Elapsed);
            stopWatch.Reset();
            stopWatch.Start();
            for (int i = 0; i < 100; i++)
            {
                MobileOperator.Serialization(SerializationType.Json);
            }
            stopWatch.Stop();
            Console.WriteLine("Serialization type JSON {0} ms", stopWatch.ElapsedMilliseconds);
            Console.WriteLine("serialization type JSon {0} ms", stopWatch.Elapsed);
            stopWatch.Reset();
            stopWatch.Start();
            for (int i = 0; i < 100; i++)
            {
                MobileOperator.Deserialization(SerializationType.Json);
            }
            stopWatch.Stop();

            Console.WriteLine("Deserialization type JSON {0} ms", stopWatch.ElapsedMilliseconds);
            Console.WriteLine("Deserialization type JSon {0} ms", stopWatch.Elapsed);
            stopWatch.Reset();
            stopWatch.Start();
            for (int i = 0; i < 100; i++)
            {
                MobileOperator.Serialization(SerializationType.Xml);
            }
            stopWatch.Stop();
            Console.WriteLine("Serialization type XML {0} ms", stopWatch.ElapsedMilliseconds);
            Console.WriteLine("serialization type XML {0} ms", stopWatch.Elapsed);

            stopWatch.Start();
            for (int i = 0; i < 100; i++)
            {
                MobileOperator.Deserialization(SerializationType.Xml);
            }
            stopWatch.Stop();
            Console.WriteLine("Deserialization type XML {0} ms", stopWatch.ElapsedMilliseconds);
            Console.WriteLine("Deserialization type XML {0} ms", stopWatch.Elapsed);
            stopWatch.Reset();

            stopWatch.Start();
            for (int i = 0; i < 100; i++)
            {
                MobileOperator.Serialization(SerializationType.Proto);
            }
            stopWatch.Stop();

            Console.WriteLine("Serialization type Proto {0} ms", stopWatch.ElapsedMilliseconds);
            Console.WriteLine("serialization type Proto {0} ms", stopWatch.Elapsed);
            stopWatch.Reset();
            stopWatch.Start();
            for (int i = 0; i < 100; i++)
            {
                MobileOperator.Deserialization(SerializationType.Proto);
            }
            stopWatch.Stop();
            Console.WriteLine("Deserialization type Proto {0} ms", stopWatch.ElapsedMilliseconds);
            Console.WriteLine("Deserialization type Proto {0} ms", stopWatch.Elapsed);

            Console.ReadKey();
        }