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(); }
public CallHandler(CellPhone phone) { phone.NewCallEvent += HandleTheCall; }
public void DetachNewCallEvent(CellPhone phone) { phone.NewCallEvent -= HandleTheCall; }
public void DetachListner(CellPhone phone) { phone.NewCallEvent -= AddNewCallLog; }