public static async Task <OperationResult <T> > BranchAsync <T>(this OperationResult <T> currentOperationResult, AsyncAction <OperationResult <T> > branchAction) { await branchAction.AssertNotNull(nameof(branchAction)) .Invoke(currentOperationResult.AssertNotNull(nameof(currentOperationResult))); return(currentOperationResult); }
public static async Task <OperationResult> BranchAsync(this OperationResult currentOperationResult, AsyncAction branchAction) { await branchAction.AssertNotNull(nameof(branchAction)) .Invoke(); return(currentOperationResult); }
public static Task <OperationResult> BranchOnFailureWhenAsync(this OperationResult currentOperationResult, Predicate condition, AsyncAction <IOperationError> branchAction) => currentOperationResult .BranchWhenAsync(x => x.IsFailure && condition.AssertNotNull(nameof(condition)) .Invoke(), x => branchAction.AssertNotNull(nameof(branchAction)) .Invoke(x.Error));
public static Task <OperationResult <T> > BranchOnFailureWhenAsync <T>(this OperationResult <T> currentOperationResult, AsyncPredicate <IOperationError> condition, AsyncAction <IOperationError> branchAction) => currentOperationResult .BranchWhenAsync(async x => x.IsFailure && await condition.AssertNotNull(nameof(condition)) .Invoke(x.Error), x => branchAction.AssertNotNull(nameof(branchAction)) .Invoke(x.Error));
public static Task <OperationResult <T> > BranchOnSuccessAsync <T>(this OperationResult <T> prevOperationResult, AsyncAction <T> branchAction) => prevOperationResult .BranchWhenAsync(x => x.IsSuccess, x => branchAction.AssertNotNull(nameof(branchAction)) .Invoke(x.Value));
public static Task <OperationResult <T> > BranchOnSuccessWhenAsync <T>(this OperationResult <T> currentOperationResult, Predicate condition, AsyncAction <T> branchAction) => currentOperationResult .BranchWhenAsync(x => x.IsSuccess && condition.AssertNotNull(nameof(condition)) .Invoke(), x => branchAction.AssertNotNull(nameof(branchAction)) .Invoke(x.Value));
public static Task <OperationResult <T> > BranchOnFailureAsync <T>(this OperationResult <T> currentOperationResult, AsyncAction <IOperationError> branchAction) => currentOperationResult .BranchWhenAsync(x => x.IsFailure, x => branchAction.AssertNotNull(nameof(branchAction)) .Invoke(x.Error));