//Обработка прихода и ухода сотрудника private void Employee_State(EmployeeEvent sender, Person person, TimeStateEventArgs time) { MessageGreet GreetByPerson = new MessageGreet(person.Greet); MessageBye ByeByPerson = new MessageBye(person.Bye); if (sender == employeeEvent) { if (employeeEvent.State == true) { Console.WriteLine("[{0} came to office]", person.Name); if (GreetByUs != null & GreetByUs != GreetByPerson) { GreetByUs(person, time); } GreetByUs += GreetByPerson; ByeByUs += ByeByPerson; } if (employeeEvent.State == false) { Console.WriteLine("[{0} leave from office]", person.Name); ByeByUs -= ByeByPerson; if (ByeByUs != null & ByeByUs != ByeByPerson) { ByeByUs(person); } } } }
public Office() { GreetByUs = null; ByeByUs = null; timeEvent = new TimeOfDayEvent(); employeeEvent = new EmployeeEvent(); timeEvent.TimeEvent += Time_State; employeeEvent.Employee += Employee_State; }