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>());
 public static Task <OperationResult> RequireAsync(this OperationResult currentOperationResult, Predicate <OperationResult> condition, AsyncFunc <IOperationError> errorBuilder)
 => currentOperationResult
 .DoWhenAsync(x => !condition.AssertNotNull(nameof(condition))
              .Invoke(x),
              async() => OperationResult.FromError(
                  await errorBuilder.AssertNotNull(nameof(errorBuilder))
                  .Invoke()));
 public static Task <OperationResult <T> > RequireAsync <T>(this OperationResult <T> currentOperationResult, AsyncPredicate <OperationResult <T> > condition, AsyncFunc <OperationResult <T>, IOperationError> errorBuilder)
 => currentOperationResult
 .DoWhenAsync(async x => !await condition.AssertNotNull(nameof(condition))
              .Invoke(x),
              async x => OperationResult <T> .FromError(
                  await errorBuilder.AssertNotNull(nameof(errorBuilder))
                  .Invoke(x)));
 public static Task <OperationResult> ContinueAsync <TPrev>(this OperationResult <TPrev> prevOperationResult, AsyncFunc <OperationResult> nextOperation)
 => nextOperation.AssertNotNull(nameof(nextOperation))
 .Invoke();
 public static Task <OperationResult> ContinueAsync(this OperationResult prevOperationResult, AsyncFunc <OperationResult, OperationResult> nextOperation)
 => nextOperation.AssertNotNull(nameof(nextOperation))
 .Invoke(prevOperationResult.AssertNotNull(nameof(prevOperationResult)));
 public static Task <OperationResult> ContinueOnFailureWhenAsync(this OperationResult prevOperationResult, Predicate condition, AsyncFunc <IOperationError, OperationResult> nextOperation)
 => prevOperationResult
 .ContinueWhenAsync(x => x.IsFailure && condition.AssertNotNull(nameof(condition))
                    .Invoke(),
                    x => nextOperation.AssertNotNull(nameof(nextOperation))
                    .Invoke(x.Error));
 public static Task <OperationResult <T> > ContinueOnFailureWhenAsync <T>(this OperationResult <T> prevOperationResult, AsyncPredicate <IOperationError> condition, AsyncFunc <IOperationError, OperationResult <T> > nextOperation)
 => prevOperationResult
 .ContinueWhenAsync(async x => x.IsFailure && await condition.AssertNotNull(nameof(condition))
                    .Invoke(x.Error),
                    x => nextOperation.AssertNotNull(nameof(nextOperation))
                    .Invoke(x.Error));
 public static Task <OperationResult <TPrimary> > DoOnSuccessAsync <TPrimary, TSecondary>(this OperationResult <TPrimary> primaryOperationResult, AsyncFunc <TPrimary, OperationResult <TSecondary> > secondaryOperation)
 => primaryOperationResult
 .DoWhenAsync(x => x.IsSuccess,
              x => secondaryOperation.AssertNotNull(nameof(secondaryOperation))
              .Invoke(x.Value));
 public static Task <OperationResult <T> > RequireOnSuccessAsync <T>(this OperationResult <T> currentOperationResult, bool condition, AsyncFunc <T, IOperationError> errorBuilder)
 => currentOperationResult
 .DoOnSuccessWhenAsync(!condition,
                       async(T x) => OperationResult.FromError(await errorBuilder.AssertNotNull(nameof(errorBuilder))
                                                               .Invoke(x)));
Ejemplo n.º 10
0
 public static Task <OperationResult <T> > ContinueOnFailureAsync <T>(this OperationResult <T> prevOperationResult, AsyncFunc <object, OperationResult <T> > recoveryOperation)
 => prevOperationResult
 .ContinueWhenAsync(x => x.IsFailure,
                    x => recoveryOperation.AssertNotNull(nameof(recoveryOperation))
                    .Invoke(prevOperationResult.Error));
Ejemplo n.º 11
0
 public static Task <OperationResult <TPrimary> > DoOnSuccessWhenAsync <TPrimary, TSecondary>(this OperationResult <TPrimary> primaryOperationResult, AsyncPredicate <TPrimary> condition, AsyncFunc <TPrimary, OperationResult <TSecondary> > secondaryOperation)
 => primaryOperationResult
 .DoWhenAsync(async x => x.IsSuccess && await condition.AssertNotNull(nameof(condition))
              .Invoke(x.Value),
              x => secondaryOperation.AssertNotNull(nameof(secondaryOperation))
              .Invoke(x.Value));
 public static Task <OperationResult> RequireAsync(this OperationResult currentOperationResult, bool condition, AsyncFunc <OperationResult, IOperationError> errorBuilder)
 => currentOperationResult
 .DoWhenAsync(!condition,
              async x => OperationResult.FromError(
                  await errorBuilder.AssertNotNull(nameof(errorBuilder))
                  .Invoke(x)));
Ejemplo n.º 13
0
 public static Task <OperationResult <TPrimary> > DoAsync <TPrimary>(this OperationResult <TPrimary> primaryOperationResult, AsyncFunc <OperationResult> secondaryOperation)
 => primaryOperationResult.DoAsync(
     secondaryOperation.AssertNotNull(nameof(secondaryOperation))
     .Invoke());
 public static Task <OperationResult <TPrimary> > DoOnFailureAsync <TPrimary, TSecondary>(this OperationResult <TPrimary> primaryOperationResult, AsyncFunc <IOperationError, OperationResult <TSecondary> > secondaryOperation)
 => primaryOperationResult
 .DoWhenAsync(x => x.IsFailure,
              x => secondaryOperation.AssertNotNull(nameof(secondaryOperation))
              .Invoke(x.Error));
 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 Task <OperationResult> RequireOnSuccessAsync(this OperationResult currentOperationResult, AsyncPredicate condition, AsyncFunc <IOperationError> errorBuilder)
 => currentOperationResult
 .DoOnSuccessWhenAsync(async() => !await condition.AssertNotNull(nameof(condition))
                       .Invoke(),
                       async() => OperationResult.FromError(await errorBuilder.AssertNotNull(nameof(errorBuilder))
                                                            .Invoke()));
 public static Task <OperationResult <T> > ContinueOnSuccessWhenAsync <T>(this OperationResult <T> prevOperationResult, Predicate condition, AsyncFunc <T, OperationResult <T> > nextOperation)
 => prevOperationResult
 .ContinueWhenAsync(x => x.IsSuccess && condition.AssertNotNull(nameof(condition))
                    .Invoke(),
                    x => nextOperation.AssertNotNull(nameof(nextOperation))
                    .Invoke(prevOperationResult.Value));
 public static Task <OperationResult> ContinueOnSuccessAsync <TPrev>(this OperationResult <TPrev> prevOperationResult, AsyncFunc <TPrev, OperationResult> nextOperation)
 => prevOperationResult
 .ContinueWhenAsync(x => x.IsSuccess,
                    x => nextOperation.AssertNotNull(nameof(nextOperation))
                    .Invoke(prevOperationResult.Value));