State/ToggleStateMember.cs

28 lines
632 B
C#

using System;
namespace Syntriax.Modules.ToggleState
{
public class ToggleStateMember : IToggleState
{
private bool _isToggled = true;
public ToggleStateMember() { }
public ToggleStateMember(bool isToggled) => IsToggled = isToggled;
public bool IsToggled
{
get => _isToggled;
set
{
if (value == _isToggled)
return;
_isToggled = value;
OnToggleStateChanged?.Invoke(value);
}
}
public Action<bool> OnToggleStateChanged { get; set; } = null;
}
}