//Обработка прихода и ухода сотрудника
        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);
                    }
                }
            }
        }
Esempio n. 2
0
        public void Greet(Person person, TimeStateEventArgs time)
        {
            if (time.eventTime == 1)
            {
                Console.WriteLine("'Good morning, {0}', {1} said.", person.Name, Name);
            }

            if (time.eventTime == 2)
            {
                Console.WriteLine("'Good afternoon, {0}', {1} said.", person.Name, Name);
            }

            if (time.eventTime == 3)
            {
                Console.WriteLine("'Good evening, {0}', {1} said.", person.Name, Name);
            }
        }
        //Обработка события смены времени
        private void Time_State(TimeOfDayEvent sender, TimeStateEventArgs time)
        {
            if (sender == timeEvent)
            {
                if (time.eventTime == 1)
                {
                    Console.WriteLine("[Time of day is before 12]");
                }

                if (time.eventTime == 2)
                {
                    Console.WriteLine("[Time of day is between 12 and 17]");
                }

                if (time.eventTime == 3)
                {
                    Console.WriteLine("[Time of day is under 17]");
                }
            }
        }