State/Runtime/Enable/StateEnableMember.cs

28 lines
618 B
C#

using System;
namespace Syntriax.Modules.State
{
public class StateEnableMember : IStateEnable
{
private bool _isEnabled = true;
public StateEnableMember() { }
public StateEnableMember(bool isEnabled) => IsEnabled = isEnabled;
public bool IsEnabled
{
get => _isEnabled;
set
{
if (value == _isEnabled)
return;
_isEnabled = value;
OnEnabledChanged?.Invoke(value);
}
}
public Action<bool> OnEnabledChanged { get; set; } = null;
}
}