コード例 #1
0
        /// <summary>
        /// Main Task02 method.
        /// </summary>
        public static void Main()
        {
            Person john = new Person {
                Name = "John"
            };
            Person paul = new Person {
                Name = "Paul"
            };
            Person george = new Person {
                Name = "George"
            };
            Person ringo = new Person {
                Name = "Ringo"
            };

            DateTime morningTime   = new DateTime(2017, 6, 27, 10, 0, 0);
            DateTime afternoonTime = new DateTime(2017, 6, 27, 13, 0, 0);
            DateTime eveningTime   = new DateTime(2017, 6, 27, 17, 0, 0);

            MessageSenderEventArgs eventArgs = new MessageSenderEventArgs(morningTime);

            john.Arrived(eventArgs);
            paul.Arrived(eventArgs);
            eventArgs = new MessageSenderEventArgs(afternoonTime);
            george.Arrived(eventArgs);
            eventArgs = new MessageSenderEventArgs(eveningTime);
            ringo.Arrived(eventArgs);

            john.Left();
            paul.Left();
            george.Left();
            ringo.Left();

            Console.ReadKey();
        }
コード例 #2
0
 /// <summary>
 /// Handles arrival event.
 /// </summary>
 /// <param name="e">Passes MessageSenderEventArgs value.</param>
 public void Arrived(MessageSenderEventArgs e)
 {
     this.Arrival += this.ArrivedMessage;
     this.OnArrival(e);
     Person.ArrivalTime = e.Time;
     Office.AddPerson(this);
 }
コード例 #3
0
 /// <summary>
 /// Messages about person arrival.
 /// </summary>
 /// <param name="sender">Passes sender value.</param>
 /// <param name="e">Passes MessageSenderEventArgs value.</param>
 private void ArrivedMessage(object sender, MessageSenderEventArgs e)
 {
     this.Write(string.Format("{0} arrived.", this.Name));
 }
コード例 #4
0
 /// <summary>
 /// Raises the event associated with the MessageSenderEventHandler delegate.
 /// </summary>
 /// <param name="e">Passes MessageSenderEventArgs parameter.</param>
 protected virtual void OnArrival(MessageSenderEventArgs e)
 {
     this.Arrival?.Invoke(this, e);
 }