State/Runtime/Enable/IStateEnableExtensions.cs

15 lines
809 B
C#

namespace Syntriax.Modules.State
{
public static class IStateEnableExtensions
{
/// <summary>
/// Checks if the provided parameter <see cref="IStateEnable"/> is enabled, if the parameter is null returns the nullValue parameter
/// </summary>
/// <param name="StateEnable"><see cref="IStateEnable"/> to be checked if enabled or not</param>
/// <param name="nullValue">The value that will be returned if <see cref="IEnabledState"/> is null. Default value: true</param>
/// <returns><see cref="IStateEnable"/>'s toggle value, or if null return nullValue parameter</returns>
public static bool IsEnabledNullChecked(this IStateEnable stateEnable, bool nullValue = true)
=> stateEnable == null ? nullValue : stateEnable.IsEnabled;
}
}