/// <summary> /// If null... /// </summary> /// <param name="this"></param> /// <param name="action"></param> /// <param name="context"></param> public static void IfNull <T>(this BooleanVal3 @this, Action <T> action, T context) { if (@this is null || @this.IsT2()) { action?.Invoke(context); } }
/// <summary> /// If null... /// </summary> /// <param name="this"></param> /// <param name="action"></param> public static void IfNull(this BooleanVal3 @this, Action action) { if (@this is null || @this.IsT2()) { action?.Invoke(); } }
/// <summary> /// If false... /// </summary> /// <param name="this"></param> /// <param name="action"></param> /// <param name="context"></param> public static void IfFalse <T>(this BooleanVal3 @this, Action <T> action, T context) { if (@this is not null && @this.IsT1()) { action?.Invoke(context); } }
/// <summary> /// If false... /// </summary> /// <param name="this"></param> /// <param name="action"></param> public static void IfFalse(this BooleanVal3 @this, Action action) { if (@this is not null && @this.IsT1()) { action?.Invoke(); } }
/// <summary> /// If this then that... /// </summary> /// <param name="condition"></param> /// <param name="this"></param> /// <param name="that"></param> /// <param name="else"></param> public static void Ifttt(this BooleanVal3 condition, Action @this, Action that, Action @else) { condition?.Switch( _ => @this?.Invoke(), _ => that?.Invoke(), _ => @else?.Invoke()); }
/// <summary> /// If this then that... /// </summary> /// <typeparam name="TValue"></typeparam> /// <param name="condition"></param> /// <param name="this"></param> /// <param name="that"></param> /// <returns></returns> public static TValue Ifttt <TValue>(this BooleanVal3 condition, Func <TValue> @this, Func <TValue> that) { if (condition is null) { return(default);