Exemplo n.º 1
0
 static void Main(string[] args)
 {
     Console.WriteLine("-----------------Events----------------");
     CellPhone phone = new CellPhone();
     CellPhonesCallLog log = new CellPhonesCallLog();
     CallHandler handler = new CallHandler(phone);
     log.AttachListner(phone);
     Console.WriteLine("--------------Calling first time with two listners");
     phone.NewCallHappened("sergey", DateTime.Now, "1234567");
     handler.DetachNewCallEvent(phone);
     Console.WriteLine("--------------Calling agian without the handler");
     phone.NewCallHappened("sergey", DateTime.Now, "1234567");
     Console.ReadLine();
 }
Exemplo n.º 2
0
 public CallHandler(CellPhone phone)
 {
     phone.NewCallEvent += HandleTheCall;
 }
Exemplo n.º 3
0
 public void DetachNewCallEvent(CellPhone phone)
 {
     phone.NewCallEvent -= HandleTheCall;
 }
 public void DetachListner(CellPhone phone)
 {
     phone.NewCallEvent -= AddNewCallLog;
 }