示例#1
0
 public void Call(MobileAccount toMobileAccount)
 {
     Console.WriteLine($"Calling from mobile number { mobileNumber } to number { toMobileAccount.mobileNumber }");
     if (CallSomeone != null)
     {
         CallSomeone(toMobileAccount, new AccountEventArgs(mobileNumber));
     }
 }
示例#2
0
 public void SendSMS(MobileAccount toMobileAccount, string message)
 {
     Console.WriteLine($"From mobile number { mobileNumber } to mobile number { toMobileAccount.mobileNumber }. Message \"{ message }\"");
     if (SentSMS != null)
     {
         SentSMS(toMobileAccount, new AccountEventArgs(mobileNumber, message));
     }
 }
示例#3
0
        public MobileAccount CreateAccount(int number)
        {
            var acc = new MobileAccount(number, this);

            _accounts.Add(number, acc);
            acc.OnMessagePost += RouteMessage;
            acc.OnCall        += RouteCall;
            return(acc);
        }
示例#4
0
 private bool ContainsAccount(MobileAccount mobileAcc)
 {
     for (int i = 0; i < users.Length; i++)
     {
         if (users[i].mobileNumber.Equals(mobileAcc.mobileNumber))
         {
             return(true);
         }
     }
     return(false);
 }
示例#5
0
 public void RouteCall(MobileAccount toMobileAccout, AccountEventArgs eventArgs)
 {
     if (ContainsAccount(toMobileAccout))
     {
         Console.WriteLine($"Calling to { toMobileAccout.mobileNumber }.");
         toMobileAccout.TakeCall(eventArgs.fromWhomNumber);
         interactions.Add(new Interaction(eventArgs.fromWhomNumber, toMobileAccout.mobileNumber, InteractionType.Call));
     }
     else
     {
         Console.WriteLine("Dialed phone number does not exist.");
     }
 }
示例#6
0
 public void RouteSMS(MobileAccount toMobileAccout, AccountEventArgs eventArgs)
 {
     if (ContainsAccount(toMobileAccout))
     {
         Console.WriteLine($"Sending SMS to { toMobileAccout.mobileNumber }. Message \"{ eventArgs.message }\"");
         toMobileAccout.ReceiveSMS(eventArgs.fromWhomNumber, eventArgs.message);
         interactions.Add(new Interaction(eventArgs.fromWhomNumber, toMobileAccout.mobileNumber, InteractionType.SMS));
     }
     else
     {
         Console.WriteLine("Such phone number does not exist.");
     }
 }