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> RequireAsync(this OperationResult currentOperationResult, AsyncPredicate <OperationResult> condition, Func <OperationResult, IOperationError> errorBuilder)
 => currentOperationResult
 .DoWhenAsync(async(FunctionalResults.OperationResult x) => !await condition.AssertNotNull(nameof(condition))
              .Invoke((FunctionalResults.OperationResult)x),
              (FunctionalResults.OperationResult x) => (FunctionalResults.OperationResult)FunctionalResults.OperationResult.FromError(
                  errorBuilder.AssertNotNull(nameof(errorBuilder))
                  .Invoke((FunctionalResults.OperationResult)x)));
 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 <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 <TPrimary> > DoOnSuccessAsync <TPrimary, TSecondary>(this OperationResult <TPrimary> primaryOperationResult, AsyncFunc <OperationResult <TSecondary> > secondaryOperation)
 => primaryOperationResult
 .DoWhenAsync(x => x.IsSuccess,
              secondaryOperation);
Пример #6
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));
Пример #7
0
 public static Task <OperationResult <TPrimary> > DoOnSuccessWhenAsync <TPrimary, TSecondary>(this OperationResult <TPrimary> primaryOperationResult, Predicate condition, AsyncFunc <OperationResult <TSecondary> > secondaryOperation)
 => primaryOperationResult
 .DoWhenAsync(x => x.IsSuccess && condition.AssertNotNull(nameof(condition))
              .Invoke(),
              secondaryOperation);
Пример #8
0
 public static Task <OperationResult <TPrimary> > DoOnSuccessWhenAsync <TPrimary>(this OperationResult <TPrimary> primaryOperationResult, bool condition, AsyncFunc <OperationResult> secondaryOperation)
 => primaryOperationResult
 .DoWhenAsync(x => x.IsSuccess && condition,
              secondaryOperation);
Пример #9
0
 public static Task <OperationResult> DoOnSuccessWhenAsync(this OperationResult primaryOperationResult, AsyncPredicate condition, AsyncFunc <OperationResult> secondaryOperation)
 => primaryOperationResult
 .DoWhenAsync(async x => x.IsSuccess && await condition.AssertNotNull(nameof(condition))
              .Invoke(),
              secondaryOperation);
 public static Task <OperationResult <T> > RequireAsync <T>(this OperationResult <T> currentOperationResult, bool condition, AsyncFunc <IOperationError> errorBuilder)
 => currentOperationResult
 .DoWhenAsync(!condition,
              async() => OperationResult <T> .FromError(
                  await errorBuilder.AssertNotNull(nameof(errorBuilder))
                  .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 <TPrimary> > DoOnFailureAsync <TPrimary>(this OperationResult <TPrimary> primaryOperationResult, AsyncFunc <OperationResult> secondaryOperation)
 => primaryOperationResult
 .DoWhenAsync(x => x.IsFailure,
              secondaryOperation);