Switch

Energy.Base.Switch is a simple boolean switch with an OnChange event. It can be implicitly converted from a bool and explicitly converted back to a bool.

Example

Energy.Base.Switch light = new Energy.Base.Switch(false);

light.OnChange += (sender, e) =>
{
    Console.WriteLine("Light state changed");
};

light.On();     // fires OnChange
light.Value = false;

bool state = (bool)light;

Properties and methods

Member Description
Value Current switch value.
On Set the switch to true.
Off Set the switch to false.
OnChange Event raised when the value changes.