api/PayrollProcessor.Core.Domain/Intrastructure/LanguageExtensions/TryOptionAsyncLanguageExtensions.cs
/// <summary>
/// Performs (at most) one of the given actions if the operation results in a None value or a failed state
/// </summary>
/// <param name="t"></param>
/// <param name="ifNone">Action to execute if the operation results in no value</param>
/// <param name="ifFail">Action to execute if the operation fails, with the exception that caused the failure</param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
Performs (at most) one of the given actions if the operation results in a None value or a failed state
Performs ( at most ) one of the given actions if the operation results in a None value or a failed state
public static TryOptionAsync<T> DoIfNoneOrFail<T>(this TryOptionAsync<T> t, Action ifNone, Action<Exception> ifFail) => async () =>
        {
            var optionResult = await t.Try();
            if (optionResult.IsFaulted)
            {
                optionResult.IfFail(ifFail);
            }
            else if (optionResult.IsNone)
            {
                optionResult.IfFailOrNone(ifNone);
            }
            return optionResult;
        };
public static TryOptionAsync < T > DoIfNoneOrFail < T > ( this TryOptionAsync < T > t , Action ifNone , Action < Exception > ifFail ) => async ( ) => { var optionResult = await t . Try ( ) ; if ( optionResult . IsFaulted ) { optionResult . IfFail ( ifFail ) ; } else if ( optionResult . IsNone ) { optionResult . IfFailOrNone ( ifNone ) ; } return optionResult ; } ;
Performs (at most) one of the given actions if the operation results in a None value or a failed state
Performs ( at most ) one of the given actions if the operation results in a None value or a failed state
None
TryOptionAsync<T>
this
ifNone
Action
Action to execute if the operation results in no value
Action to execute if the operation results in no value
ifFail
Action<Exception>
Action to execute if the operation fails, with the exception that caused the failure
Action to execute if the operation fails with the exception that caused the failure
t
None
typeparam
None