コード例 #1
0
        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);
        }
コード例 #2
0
        public static async Task <OperationResult> BranchAsync(this OperationResult currentOperationResult, AsyncAction branchAction)
        {
            await branchAction.AssertNotNull(nameof(branchAction))
            .Invoke();

            return(currentOperationResult);
        }
コード例 #3
0
 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));
コード例 #4
0
 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));
コード例 #5
0
 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));
コード例 #6
0
 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));
コード例 #7
0
 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));