public OfficeEventListener(Person person, IList<Person> persons)
 {
     _persons = persons;
     _person = person;
     _person.ComeEvent += new PersonEventHandler(PersonCame);
     _person.LeftEvent += new PersonEventHandler(PersonLeft);
 }
 public void Detach()
 {
     // Detach the event and delete the list
     _person.ComeEvent -= new PersonEventHandler(PersonCame);
     _person.LeftEvent -= new PersonEventHandler(PersonLeft);
     _person = null;
 }
        static void Main(string[] args)
        {
            var persons = new List<Person>();
            var person1 = new Person("Петя");
            var person2 = new Person("Вова");
            var person3 = new Person("Дима");
            OfficeEventListener officeEventListener1 = new OfficeEventListener(person1, persons);
            OfficeEventListener officeEventListener2 = new OfficeEventListener(person2, persons);
            OfficeEventListener officeEventListener3 = new OfficeEventListener(person3, persons);
            person3.Come(new DateTime(2014, 04, 22, 18, 24, 00));
            person1.Come(new DateTime(2014, 04, 22, 10, 24, 00));
            person2.Come(new DateTime(2014, 04, 22, 13, 24, 00));

            Console.ReadLine();
        }
        public void SayHello(Person person, DateTime time)
        {
            string greeting;
            if (time.Hour < 12)
            {
                greeting = "Доброе утро";
            }
            else if (time.Hour > 12 && time.Hour < 17)
            {
                greeting = "Добрый день";
            }
            else
            {
                greeting = "Добрый вечер";
            }

            Console.WriteLine("\"{0},{1}!\", - сказал {2}", greeting, person.Name, Name);
        }
 public void SayGoodBye(Person person)
 {
     Console.WriteLine("\"До свидания,{0}!\", - сказал {1}", person.Name, Name);
 }
 public EmployeeEventArgs(Person person, DateTime time)
     : this(person)
 {
     Time = time;
 }
 public EmployeeEventArgs(Person person)
 {
     Person = person;
 }