Пример #1
0
 //Plus on VoidResult<TError>
 public static VoidResult <TError> Plus <TError>(this VoidResult <TError> left, VoidResult <TError> right, Func <TError, TError, TError> mergeFunc)
 => left.Match(
     leftValue => right.Match(
         rightValue => Ok <TError>(), Fail
         ),
     error => right.Match(
         rightValue => Fail(error),
         otherError => Fail(mergeFunc.ThrowIfDefault(nameof(mergeFunc))(error, otherError))
         )
     );
Пример #2
0
 //Flatten on VoidResult<TError>
 public static VoidResult <TError> Flatten <TError>(this VoidResult <VoidResult <TError> > value)
 => value.Match(_ => Ok <TError>(), Id);
Пример #3
0
 //Plus on VoidResult
 public static VoidResult Plus(this VoidResult left, VoidResult right)
 => left.Match(
     leftValue => right.Match(_ => Ok(), Fail),
     error => right.Match(rightValue => Fail(error), otherError => Fail(error.Concat(otherError)))
     );