Ejemplo n.º 1
0
        public bool AddMobileAccount(MobileAccount mobileAccount)
        {
            var results = new List <ValidationResult>();
            var context = new ValidationContext(mobileAccount);

            if (!Validator.TryValidateObject(mobileAccount, context, results, true))
            {
                foreach (var error in results)
                {
                    Console.WriteLine(error.ErrorMessage);
                }
                return(false);
            }

            if (List.Exists(x => x.Id == mobileAccount.Id))
            {
                return(false);
            }
            mobileAccount.Id = _mobileIdCount;
            List.Add(mobileAccount);
            mobileAccount.SendSMS += OnSMS;
            mobileAccount.Called  += OnCall;
            mobileAccount.GotSMS  += OnGotSMS;
            mobileAccount.GotCall += OnGotCall;
            _mobileIdCount++;
            return(true);
        }
Ejemplo n.º 2
0
 public bool AddMobileAccount(MobileAccount mobileAccount)
 {
     if (_list.Exists(x => x.Id == mobileAccount.Id))
     {
         return(false);
     }
     _list.Add(mobileAccount);
     mobileAccount.SendSMS += OnSMS;
     mobileAccount.Called  += OnCall;
     mobileAccount.GotSMS  += OnGotSMS;
     mobileAccount.GotCall += OnGotCall;
     return(true);
 }
        public void Start()
        {
            MobileOperator mobileOperator = new MobileOperator();
            var            mobile1        = new MobileAccount(1);
            var            mobile2        = new MobileAccount(2);
            var            mobile3        = new MobileAccount(3);
            var            mobile4        = new MobileAccount(4);
            var            mobile5        = new MobileAccount(5);

            mobile5.Contacts.Add("Alex1", mobile1);
            mobile3.Contacts.Add("Alex1", mobile1);
            mobile2.Contacts.Add("Alex1", mobile1);

            mobile1.Contacts.Add("mobile5", mobile5);
            mobile1.Contacts.Add("mobile3", mobile3);
            mobile1.Contacts.Add("mobile2", mobile2);

            mobileOperator.AddMobileAccount(mobile1);
            mobileOperator.AddMobileAccount(mobile2);
            mobileOperator.AddMobileAccount(mobile3);
            mobileOperator.AddMobileAccount(mobile4);
            mobileOperator.AddMobileAccount(mobile5);

            mobile1.CallOut(mobile3.Id);
            mobile3.CallOut(mobile5.Id);
            mobile2.CallOut(mobile1.Id);
            mobile1.CallOut(mobile3.Id);
            mobile2.CallOut(49);

            mobile1.SMSOut(mobile3.Id);
            mobile3.SMSOut(mobile5.Id);
            mobile2.SMSOut(mobile1.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile2.SMSOut(50);

            Console.ReadLine();
        }
        public void Start()
        {
            MobileOperator mobileOperator = new MobileOperator();
            var            mobile1        = new MobileAccount(1);
            var            mobile2        = new MobileAccount(2);
            var            mobile3        = new MobileAccount(3);
            var            mobile4        = new MobileAccount(4);
            var            mobile5        = new MobileAccount(5);
            var            mobile6        = new MobileAccount(6);
            var            mobile7        = new MobileAccount(7);
            var            mobile8        = new MobileAccount(8);
            var            mobile9        = new MobileAccount(9);

            mobile5.Contacts.Add("Alex1", mobile1);
            mobile3.Contacts.Add("Alex1", mobile1);
            mobile2.Contacts.Add("Alex1", mobile1);

            mobile1.Contacts.Add("mobile5", mobile5);
            mobile1.Contacts.Add("mobile3", mobile3);
            mobile1.Contacts.Add("mobile2", mobile2);

            mobileOperator.AddMobileAccount(mobile1);
            mobileOperator.AddMobileAccount(mobile2);
            mobileOperator.AddMobileAccount(mobile3);
            mobileOperator.AddMobileAccount(mobile4);
            mobileOperator.AddMobileAccount(mobile5);
            mobileOperator.AddMobileAccount(mobile6);
            mobileOperator.AddMobileAccount(mobile7);
            mobileOperator.AddMobileAccount(mobile8);
            mobileOperator.AddMobileAccount(mobile9);

            mobile1.CallOut(mobile3.Id);
            mobile2.CallOut(mobile3.Id);
            mobile3.CallOut(mobile3.Id);
            mobile4.CallOut(mobile3.Id);
            mobile5.CallOut(mobile3.Id);
            mobile6.CallOut(mobile5.Id);
            mobile2.CallOut(mobile1.Id);
            mobile7.CallOut(mobile3.Id);
            mobile8.CallOut(mobile3.Id);
            mobile9.CallOut(mobile3.Id);
            mobile1.CallOut(mobile9.Id);
            mobile2.CallOut(mobile8.Id);
            mobile3.CallOut(mobile7.Id);
            mobile4.CallOut(mobile6.Id);
            mobile5.CallOut(mobile5.Id);
            mobile6.CallOut(mobile4.Id);
            mobile2.CallOut(mobile3.Id);
            mobile7.CallOut(mobile2.Id);
            mobile8.CallOut(mobile1.Id);
            mobile9.CallOut(mobile3.Id);
            mobile1.CallOut(mobile3.Id);
            mobile1.CallOut(mobile3.Id);
            mobile3.CallOut(mobile5.Id);
            mobile2.CallOut(mobile1.Id);
            mobile1.CallOut(mobile3.Id);
            mobile1.CallOut(mobile3.Id);
            mobile3.CallOut(mobile5.Id);
            mobile2.CallOut(mobile1.Id);
            mobile1.CallOut(mobile3.Id);
            mobile2.CallOut(49);

            mobile1.SMSOut(mobile3.Id);
            mobile3.SMSOut(mobile5.Id);
            mobile2.SMSOut(mobile1.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile3.SMSOut(mobile5.Id);
            mobile2.SMSOut(mobile1.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile3.SMSOut(mobile5.Id);
            mobile2.SMSOut(mobile1.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile3.SMSOut(mobile5.Id);
            mobile2.SMSOut(mobile1.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile2.SMSOut(50);

            mobileOperator.GetStaticstic();

            Console.ReadLine();
        }
Ejemplo n.º 5
0
        public void Start()
        {
            MobileOperator mobileOperator = new MobileOperator();
            var            mobile1        = new MobileAccount("1", "Shevchuk1", DateTime.Today, "*****@*****.**");
            var            mobile2        = new MobileAccount(null, "Shevchuk2", DateTime.Today, "*****@*****.**");
            var            mobile3        = new MobileAccount("Alex3", "Shevchuk3", DateTime.Today, "*****@*****.**");
            var            mobile4        = new MobileAccount("Alex4", "Shevchuk4", DateTime.Today, "*****@*****.**");
            var            mobile5        = new MobileAccount("Alex5", "Shevchuk5", DateTime.Today, "*****@*****.**");
            var            mobile6        = new MobileAccount("Alex6", "Shevchuk6", DateTime.Today, "*****@*****.**");
            var            mobile7        = new MobileAccount("Alex7", "Shevchuk7", DateTime.Today, "*****@*****.**");
            var            mobile8        = new MobileAccount("Alex8", "Shevchuk8", DateTime.Today, "*****@*****.**");
            var            mobile9        = new MobileAccount("Alex9", "Shevchuk9", DateTime.Today, "*****@*****.**");

            mobileOperator.AddMobileAccount(mobile1);
            mobileOperator.AddMobileAccount(mobile2);
            mobileOperator.AddMobileAccount(mobile3);
            mobileOperator.AddMobileAccount(mobile4);
            mobileOperator.AddMobileAccount(mobile5);
            mobileOperator.AddMobileAccount(mobile6);
            mobileOperator.AddMobileAccount(mobile7);
            mobileOperator.AddMobileAccount(mobile8);
            mobileOperator.AddMobileAccount(mobile9);

            mobile1.Name = "1";
            mobile5.Contacts.Add("Alex1", mobile1.Id);
            mobile3.Contacts.Add("Alex1", mobile1.Id);
            mobile2.Contacts.Add("Alex1", mobile1.Id);

            mobile1.Contacts.Add("mobile5", mobile5.Id);
            mobile1.Contacts.Add("mobile3", mobile3.Id);
            mobile1.Contacts.Add("mobile2", mobile2.Id);

            mobile1.CallOut(mobile3.Id);
            mobile2.CallOut(mobile3.Id);
            mobile3.CallOut(mobile3.Id);
            mobile4.CallOut(mobile3.Id);
            mobile5.CallOut(mobile3.Id);
            mobile6.CallOut(mobile5.Id);
            mobile2.CallOut(mobile1.Id);
            mobile7.CallOut(mobile3.Id);
            mobile8.CallOut(mobile3.Id);
            mobile9.CallOut(mobile3.Id);
            mobile1.CallOut(mobile9.Id);
            mobile2.CallOut(mobile8.Id);
            mobile3.CallOut(mobile7.Id);
            mobile4.CallOut(mobile6.Id);
            mobile5.CallOut(mobile5.Id);
            mobile6.CallOut(mobile4.Id);
            mobile2.CallOut(mobile3.Id);
            mobile7.CallOut(mobile2.Id);
            mobile8.CallOut(mobile1.Id);
            mobile9.CallOut(mobile3.Id);
            mobile1.CallOut(mobile3.Id);
            mobile1.CallOut(mobile3.Id);
            mobile3.CallOut(mobile5.Id);
            mobile2.CallOut(mobile1.Id);
            mobile1.CallOut(mobile3.Id);
            mobile1.CallOut(mobile3.Id);
            mobile3.CallOut(mobile5.Id);
            mobile2.CallOut(mobile1.Id);
            mobile1.CallOut(mobile3.Id);
            mobile2.CallOut(49);

            mobile1.SMSOut(mobile3.Id);
            mobile3.SMSOut(mobile5.Id);
            mobile2.SMSOut(mobile1.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile3.SMSOut(mobile5.Id);
            mobile2.SMSOut(mobile1.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile3.SMSOut(mobile5.Id);
            mobile2.SMSOut(mobile1.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile3.SMSOut(mobile5.Id);
            mobile2.SMSOut(mobile1.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile2.SMSOut(50);

            mobileOperator.GetStaticstic();

            var ticks = DateTime.Now.Ticks;

            mobileOperator.BinarySerialize();
            Console.WriteLine("BinarySerialize - {0}", DateTime.Now.Ticks - ticks);
            mobileOperator.Clear();

            ticks = DateTime.Now.Ticks;
            mobileOperator.BinaryDeserialize();
            Console.WriteLine("BinaryDeserialize - {0}", DateTime.Now.Ticks - ticks);
            mobileOperator.GetStaticstic();
            foreach (var item in mobile1.Contacts)
            {
                Console.WriteLine(item.Key);
            }

            ticks = DateTime.Now.Ticks;
            mobileOperator.JsonSerialize();
            Console.WriteLine("JsonSerialize - {0}", DateTime.Now.Ticks - ticks);
            mobileOperator.Clear();

            ticks = DateTime.Now.Ticks;
            mobileOperator.JsonDeserialize();
            Console.WriteLine("JsonDeserialize - {0}", DateTime.Now.Ticks - ticks);
            mobileOperator.GetStaticstic();
            foreach (var item in mobile1.Contacts)
            {
                Console.WriteLine(item.Key);
            }

            ticks = DateTime.Now.Ticks;
            mobileOperator.XMLSerialize();
            Console.WriteLine("XMLSerialize - {0}", DateTime.Now.Ticks - ticks);
            mobileOperator.Clear();

            ticks = DateTime.Now.Ticks;
            mobileOperator.XMLDeserialize();
            Console.WriteLine("XMLDeserialize - {0}", DateTime.Now.Ticks - ticks);
            mobileOperator.GetStaticstic();
            foreach (var item in mobile1.Contacts)
            {
                Console.WriteLine(item.Key);
            }

            ticks = DateTime.Now.Ticks;
            mobileOperator.ProtoBufSerialize();
            Console.WriteLine("ProtoBufSerialize - {0}", DateTime.Now.Ticks - ticks);
            mobileOperator.Clear();

            ticks = DateTime.Now.Ticks;
            mobileOperator.ProtoBufDeserialize();
            Console.WriteLine("ProtoBufDeserialize - {0}", DateTime.Now.Ticks - ticks);
            mobileOperator.GetStaticstic();
            foreach (var item in mobile1.Contacts)
            {
                Console.WriteLine(item.Key);
            }

            Console.ReadLine();
        }
Ejemplo n.º 6
0
        public void Start()
        {
            MobileOperator mobileOperator = new MobileOperator();
            var            mobile1        = new MobileAccount("1", "Shevchuk1", DateTime.Today, "*****@*****.**");
            var            mobile2        = new MobileAccount(null, "Shevchuk2", DateTime.Today, "*****@*****.**");
            var            mobile3        = new MobileAccount("Alex3", "Shevchuk3", DateTime.Today, "*****@*****.**");
            var            mobile4        = new MobileAccount("Alex4", "Shevchuk4", DateTime.Today, "*****@*****.**");
            var            mobile5        = new MobileAccount("Alex5", "Shevchuk5", DateTime.Today, "*****@*****.**");
            var            mobile6        = new MobileAccount("Alex6", "Shevchuk6", DateTime.Today, "*****@*****.**");
            var            mobile7        = new MobileAccount("Alex7", "Shevchuk7", DateTime.Today, "*****@*****.**");
            var            mobile8        = new MobileAccount("Alex8", "Shevchuk8", DateTime.Today, "*****@*****.**");
            var            mobile9        = new MobileAccount("Alex9", "Shevchuk9", DateTime.Today, "*****@*****.**");

            mobile1.Name = "1";
            mobile5.Contacts.Add("Alex1", mobile1);
            mobile3.Contacts.Add("Alex1", mobile1);
            mobile2.Contacts.Add("Alex1", mobile1);

            mobile1.Contacts.Add("mobile5", mobile5);
            mobile1.Contacts.Add("mobile3", mobile3);
            mobile1.Contacts.Add("mobile2", mobile2);

            mobileOperator.AddMobileAccount(mobile1);
            mobileOperator.AddMobileAccount(mobile2);
            mobileOperator.AddMobileAccount(mobile3);
            mobileOperator.AddMobileAccount(mobile4);
            mobileOperator.AddMobileAccount(mobile5);
            mobileOperator.AddMobileAccount(mobile6);
            mobileOperator.AddMobileAccount(mobile7);
            mobileOperator.AddMobileAccount(mobile8);
            mobileOperator.AddMobileAccount(mobile9);

            mobile1.CallOut(mobile3.Id);
            mobile2.CallOut(mobile3.Id);
            mobile3.CallOut(mobile3.Id);
            mobile4.CallOut(mobile3.Id);
            mobile5.CallOut(mobile3.Id);
            mobile6.CallOut(mobile5.Id);
            mobile2.CallOut(mobile1.Id);
            mobile7.CallOut(mobile3.Id);
            mobile8.CallOut(mobile3.Id);
            mobile9.CallOut(mobile3.Id);
            mobile1.CallOut(mobile9.Id);
            mobile2.CallOut(mobile8.Id);
            mobile3.CallOut(mobile7.Id);
            mobile4.CallOut(mobile6.Id);
            mobile5.CallOut(mobile5.Id);
            mobile6.CallOut(mobile4.Id);
            mobile2.CallOut(mobile3.Id);
            mobile7.CallOut(mobile2.Id);
            mobile8.CallOut(mobile1.Id);
            mobile9.CallOut(mobile3.Id);
            mobile1.CallOut(mobile3.Id);
            mobile1.CallOut(mobile3.Id);
            mobile3.CallOut(mobile5.Id);
            mobile2.CallOut(mobile1.Id);
            mobile1.CallOut(mobile3.Id);
            mobile1.CallOut(mobile3.Id);
            mobile3.CallOut(mobile5.Id);
            mobile2.CallOut(mobile1.Id);
            mobile1.CallOut(mobile3.Id);
            mobile2.CallOut(49);

            mobile1.SMSOut(mobile3.Id);
            mobile3.SMSOut(mobile5.Id);
            mobile2.SMSOut(mobile1.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile3.SMSOut(mobile5.Id);
            mobile2.SMSOut(mobile1.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile3.SMSOut(mobile5.Id);
            mobile2.SMSOut(mobile1.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile3.SMSOut(mobile5.Id);
            mobile2.SMSOut(mobile1.Id);
            mobile1.SMSOut(mobile3.Id);
            mobile2.SMSOut(50);

            mobileOperator.GetStaticstic();

            Console.ReadLine();
        }