using System;
namespace Chernobyl.Switch
{
///
/// Known as an "OR Gate" in boolean logic, this switch will fire the event
/// when
/// or have been invoked.
///
public class OrSwitch : ISwitch
{
///
/// An event handler that can be assigned to an event. When this method
/// is invoked, it will invoke the
/// event.
///
/// The sender of the event.
/// The instance
/// containing the event data.
public void Switch1(object sender, EventArgs e)
{
if (SwitchedOn != null)
SwitchedOn(this, e);
}
///
/// An event handler that can be assigned to an event. When this method
/// is invoked, it will invoke the
/// event.
///
/// The sender of the event.
/// The instance
/// containing the event data.
public void Switch2(object sender, EventArgs e)
{
if (SwitchedOn != null)
SwitchedOn(this, e);
}
///
/// An event that is raised when this switch has been switched on.
///
public event EventHandler SwitchedOn;
///
/// An event that is raised right after this switch has been switched
/// off (or reset).
///
public event EventHandler SwitchedOff;
///
/// Resets the switch to its original state or the its state after right
/// after its creation.
///
public void Reset()
{
if (SwitchedOff != null)
SwitchedOff(this, EventArgs.Empty);
}
///
/// An event handler that can be assigned to an event. This event handler
/// will reset the switch to its original state. It is exactly the same
/// as calling .
///
/// The sender of the event.
/// The arguments to the event.
public void Reset(object sender, EventArgs e)
{
Reset();
}
}
}