public static OperationResult <TNext> ContinueOnSuccess <TPrev, TNext>(this OperationResult <TPrev> prevOperationResult, Func <TPrev, OperationResult <TNext> > nextOperation)
 => prevOperationResult.AssertNotNull(nameof(prevOperationResult))
 .IsSuccess
         ? prevOperationResult
 .Continue(x => nextOperation.AssertNotNull(nameof(nextOperation))
           .Invoke(prevOperationResult.Value))
         : prevOperationResult.AsFailure <TNext>();
예제 #2
0
        public static OperationResult <T> Branch <T>(this OperationResult <T> currentOperationResult, Action <OperationResult <T> > branchAction)
        {
            branchAction.AssertNotNull(nameof(branchAction))
            .Invoke(currentOperationResult.AssertNotNull(nameof(currentOperationResult)));

            return(currentOperationResult);
        }
 public static Task <OperationResult <TNext> > ContinueOnSuccessAsync <TPrev, TNext>(this OperationResult <TPrev> prevOperationResult, AsyncFunc <TPrev, OperationResult <TNext> > nextOperation)
 => prevOperationResult.AssertNotNull(nameof(prevOperationResult))
 .IsSuccess
         ? prevOperationResult
 .ContinueAsync(x => nextOperation.AssertNotNull(nameof(nextOperation))
                .Invoke(prevOperationResult.Value))
         : Task.FromResult(prevOperationResult.AsFailure <TNext>());
예제 #4
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);
        }
예제 #5
0
 public static OperationResult <T> ContinueWhen <T>(this OperationResult <T> prevOperationResult, Predicate <OperationResult <T> > condition, Func <OperationResult <T>, OperationResult <T> > nextOperation)
 => prevOperationResult
 .ContinueWhen(
     condition.AssertNotNull(nameof(condition))
     .Invoke(prevOperationResult.AssertNotNull(nameof(prevOperationResult))),
     nextOperation);
예제 #6
0
 public static async Task <OperationResult <T> > ContinueWhenAsync <T>(this OperationResult <T> prevOperationResult, AsyncPredicate <OperationResult <T> > condition, AsyncFunc <OperationResult <T>, OperationResult <T> > nextOperation)
 => await prevOperationResult
 .ContinueWhenAsync(
     await condition.AssertNotNull(nameof(condition))
     .Invoke(prevOperationResult.AssertNotNull(nameof(prevOperationResult))),
     nextOperation);
예제 #7
0
 public static Task <OperationResult> ContinueWhenAsync(this OperationResult prevOperationResult, Predicate <OperationResult> condition, AsyncFunc <OperationResult, OperationResult> nextOperation)
 => prevOperationResult
 .ContinueWhenAsync(
     condition.AssertNotNull(nameof(condition))
     .Invoke(prevOperationResult.AssertNotNull(nameof(prevOperationResult))),
     nextOperation);
예제 #8
0
 public static OperationResult Do(this OperationResult primaryOperationResult, OperationResult secondaryOperationResult)
 => secondaryOperationResult.AssertNotNull(nameof(secondaryOperationResult))
 .IsSuccess
             ? primaryOperationResult
             : secondaryOperationResult;
 public static Task <OperationResult> ContinueAsync(this OperationResult prevOperationResult, AsyncFunc <OperationResult, OperationResult> nextOperation)
 => nextOperation.AssertNotNull(nameof(nextOperation))
 .Invoke(prevOperationResult.AssertNotNull(nameof(prevOperationResult)));
예제 #10
0
 public static Task <OperationResult> DoAsync(this Task <OperationResult> primaryOperationResult, OperationResult secondaryOperationResult)
 => secondaryOperationResult.AssertNotNull(nameof(secondaryOperationResult))
 .IsSuccess
             ? primaryOperationResult
             : Task.FromResult(secondaryOperationResult);
예제 #11
0
 public static OperationResult <TResult> Combine <T1, T2, TResult>(OperationResult <T1> operationResult1, OperationResult <T2> operationResult2, Func <T1, T2, TResult> combiner)
 => operationResult1.AssertNotNull(nameof(operationResult1)).IsFailure ? OperationResult <TResult> .FromError(operationResult1.Error)
         : operationResult2.AssertNotNull(nameof(operationResult2)).IsFailure ? OperationResult <TResult> .FromError(operationResult2.Error)
         : OperationResult <TResult> .FromResult(combiner.AssertNotNull(nameof(combiner)).Invoke(operationResult1.Value, operationResult2.Value));
 public static OperationResult <T> BranchWhen <T>(this OperationResult <T> prevOperationResult, Predicate <OperationResult <T> > condition, Action <OperationResult <T> > branchAction)
 => condition.AssertNotNull(nameof(condition))
 .Invoke(prevOperationResult.AssertNotNull(nameof(prevOperationResult)))
         ? prevOperationResult
 .Branch(branchAction)
         : prevOperationResult;
 public static async Task <OperationResult <T> > BranchWhenAsync <T>(this OperationResult <T> prevOperationResult, AsyncPredicate <OperationResult <T> > condition, AsyncAction <OperationResult <T> > branchAction)
 => await condition.AssertNotNull(nameof(condition))
 .Invoke(prevOperationResult.AssertNotNull(nameof(prevOperationResult)))
         ? await prevOperationResult
 .BranchAsync(branchAction)
         : prevOperationResult;
 public static Task <OperationResult <T> > BranchWhenAsync <T>(this OperationResult <T> prevOperationResult, Predicate <OperationResult <T> > condition, AsyncAction <OperationResult <T> > branchAction)
 => condition.AssertNotNull(nameof(condition))
 .Invoke(prevOperationResult.AssertNotNull(nameof(prevOperationResult)))
         ? prevOperationResult
 .BranchAsync(branchAction)
         : Task.FromResult(prevOperationResult);
예제 #15
0
 public static Task <OperationResult <TPrimary> > DoAsync <TPrimary, TSecondary>(this Task <OperationResult <TPrimary> > primaryOperationResult, OperationResult <TSecondary> secondaryOperationResult)
 => secondaryOperationResult.AssertNotNull(nameof(secondaryOperationResult))
 .IsSuccess
             ? primaryOperationResult
             : Task.FromResult(secondaryOperationResult.AsFailure <TPrimary>());
 public static OperationResult Continue <TPrev>(this OperationResult <TPrev> prevOperationResult, Func <OperationResult <TPrev>, OperationResult> nextOperation)
 => nextOperation.AssertNotNull(nameof(nextOperation))
 .Invoke(prevOperationResult.AssertNotNull(nameof(prevOperationResult)));
예제 #17
0
 public static OperationResult <TPrimary> Do <TPrimary, TSecondary>(this OperationResult <TPrimary> primaryOperationResult, OperationResult <TSecondary> secondaryOperationResult)
 => secondaryOperationResult.AssertNotNull(nameof(secondaryOperationResult))
 .IsSuccess
             ? primaryOperationResult
             : secondaryOperationResult.AsFailure <TPrimary>();
 public static Task <OperationResult <TNext> > ContinueAsync <TPrev, TNext>(this OperationResult <TPrev> prevOperationResult, AsyncFunc <OperationResult <TPrev>, OperationResult <TNext> > nextOperation)
 => nextOperation.AssertNotNull(nameof(nextOperation))
 .Invoke(prevOperationResult.AssertNotNull(nameof(prevOperationResult)));
 public static OperationResult <TNext> ContinueOnSuccess <TNext>(this OperationResult prevOperationResult, Func <OperationResult <TNext> > nextOperation)
 => prevOperationResult.AssertNotNull(nameof(prevOperationResult))
 .IsSuccess
         ? prevOperationResult
 .Continue(nextOperation)
         : prevOperationResult.AsFailure <TNext>();