コード例 #1
0
        static void Main(string[] args)
        {
            List <MobileAccount> mobileAccounts = new List <MobileAccount>();
            Dictionary <MobileAccount, MobileAccount> keyValuePairs = new Dictionary <MobileAccount, MobileAccount>();

            MobileAccount mobile1 = new MobileAccount("Artur", "Sitnichenko", "*****@*****.**", new DateTime(1997, 1, 9));

            mobileAccounts.Add(mobile1);
            MobileAccount mobile2 = new MobileAccount("Kolya", "Sitnichenko", "*****@*****.**", new DateTime(1997, 1, 9));

            mobileAccounts.Add(mobile2);

            MobileAccount mobile3 = new MobileAccount("Masha", "Sitnichenko", "*****@*****.**", new DateTime(1997, 1, 9));
            MobileAccount mobile4 = new MobileAccount("Pasha", "Sitnichenko", "*****@*****.**", new DateTime(1997, 1, 9));

            mobileAccounts.Add(mobile3);
            mobileAccounts.Add(mobile4);

            Console.WriteLine(new string('-', 30));
            mobile1.AddAccount(new Account {
                Name = "Dima", PhoneNumber = mobile2.Number
            });

            SerializeAll(mobileAccounts);
        }
コード例 #2
0
        public static bool JsonSerializer(MobileAccount account)
        {
            DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(MobileAccount));

            using (FileStream fs = new FileStream(account.Number + "JSON" + ".json", FileMode.OpenOrCreate))
            {
                jsonSerializer.WriteObject(fs, account);
                return(true);
            }

            return(false);
        }
コード例 #3
0
        public static bool XmlSerializer(MobileAccount account)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(MobileAccount));

            using (FileStream fs = new FileStream(account.Number + "XML" + ".xml", FileMode.OpenOrCreate))
            {
                xmlSerializer.Serialize(fs, account);
                return(true);
            }

            return(false);
        }
コード例 #4
0
        public static bool BinarySerializer(MobileAccount account)
        {
            BinaryFormatter formatter = new BinaryFormatter();

            using (FileStream fs = new FileStream(account.Number + "Binary" + ".dat", FileMode.OpenOrCreate))
            {
                formatter.Serialize(fs, account);
                return(true);
            }

            return(false);
        }
コード例 #5
0
        public static string AddNewMobileAcount(MobileAccount mobileAccount, MethodToCalledNumber CallNumberMethod,
                                                MethodToCalledNumber MailNumberMethod)
        {
            if (mobileAccount.Validate())
            {
                callDelegate.Add(mobileAccount, CallNumberMethod);
                mailDelegate.Add(mobileAccount, MailNumberMethod);

                mobileAccount.CallEvent += MobileAccount_callevent;
                mobileAccount.MailEvent += MobileAccount_mailevent;

                string number = GenerateNewNumber();
                accounts.Add(mobileAccount);


                return(number);
            }
            return("");
        }
コード例 #6
0
 public void Call(MobileAccount account)
 {
     Call(account.Number);
 }
コード例 #7
0
 public void SendMail(MobileAccount account)
 {
     SendMail(account.Number);
 }