Beispiel #1
0
 //method which gets the event args
 protected virtual void RaiseSwitchFlipped(SwitchFlippedEventArgs args)
 {
     // We must check that the event is not null.  It is null
     //  if no one registered to the event.
     //
     if (SwitchFlipped != null)
     {
         SwitchFlipped(this, args);
     }
 }
Beispiel #2
0
        public void Flip()
        {
            if (_state == SwitchState.Off)
            {
                _state = SwitchState.On;
            }
            else
            {
                _state = SwitchState.Off;
            }

            // We call the protected method that raises the event.
            SwitchFlippedEventArgs eventArgs = new SwitchFlippedEventArgs(_state);

            RaiseSwitchFlipped(eventArgs);
        }
Beispiel #3
0
 public static void OnSwitchFlipped(object sender, SwitchFlippedEventArgs args)
 {
     Console.WriteLine("This is the Light, switch flipped to state: " + args.State);
 }
Beispiel #4
0
 static void OnSwitchFlipped(object sender, SwitchFlippedEventArgs args)
 {
     Console.WriteLine("Switch flipped to state: " + args.State);
 }