Exemple #1
0
        public static Outcome <ResultType> Map <T, ResultType>(this Outcome <T> @this, Func <T, ValueTuple <ResultType, Failure> > fn)
        {
            if ([email protected])
            {
                return(Outcome <ResultType> .Reject(@this.FailureOrNull()));
            }

            return(Try <ResultType>(() => fn(@this.ResultOrDefault())));
        }
Exemple #2
0
        public static Outcome <ResultType> Map <T, ResultType>(this Outcome <T> @this, Func <ResultType> fn)
        {
            if ([email protected])
            {
                return(Outcome <ResultType> .Reject(@this.FailureOrNull()));
            }

            return(Outcome.Of(fn));
        }
        public static Outcome <ResultType> Then <T, ResultType>(this Outcome <T> @this, Func <T, ResultType> fn)
        {
            if ([email protected])
            {
                return(Outcome <ResultType> .Reject(@this.FailureOrNull()));
            }

            return(Outcome.Of(() => fn(@this.ResultOrDefault())));
        }
Exemple #4
0
        public static async Task <Outcome <ReturnType> > Then <T, ReturnType>(this Outcome <T> outcome, Func <T, Task <Outcome <ReturnType> > > asyncFunc)
        {
            return(await Try(async() => {
                if (outcome.IsSuccessful)
                {
                    return await asyncFunc(outcome.ResultOrDefault());
                }

                return Outcome <ReturnType> .Reject(outcome.FailureOrNull());
            }));
        }
Exemple #5
0
        public static Task <Outcome <ReturnType> > Map <T, ReturnType>(this Outcome <T> outcome, Func <Task <ReturnType> > asyncFunc)
        {
            if (outcome.IsSuccessful)
            {
                return(Outcome.Of(asyncFunc));
            }

            return(Outcome <ReturnType>
                   .Reject(outcome.FailureOrNull())
                   .ForAsync());
        }
Exemple #6
0
        public static Task <Outcome <ReturnType> > Map <T, ReturnType>(this Outcome <T> outcome, Func <T, Task <Outcome <ReturnType> > > asyncFunc)
        {
            return(Try(() => {
                if (outcome.IsSuccessful)
                {
                    return asyncFunc(outcome.ResultOrDefault());
                }

                return Outcome <ReturnType>
                .Reject(outcome.FailureOrNull())
                .ForAsync();
            }));
        }
Exemple #7
0
 public static async Task <Outcome <ReturnType> > Continue <T, ReturnType>
     (this Outcome <T> @this, Func <T, Failure, Task <ReturnType> > fn) => await fn(@this.ResultOrDefault(), @this.FailureOrNull());
Exemple #8
0
 public static Outcome <ReturnType> Continue <T, ReturnType>
     (this Outcome <T> @this, Func <T, Failure, Outcome <ReturnType> > fn) => fn(@this.ResultOrDefault(), @this.FailureOrNull());
 internal static Outcome <T> ToKnownFailed <T>(Outcome <T> failed)
 {
     Debug.Assert(!failed.IsSuccessful);
     return(Outcome <T> .Reject(new KnownFailure(failed.FailureOrNull())));
 }
 internal static bool IsIgnorable <T>(Outcome <T> @this) =>
 @this.IsSuccessful || @this.FailureOrNull() is KnownFailure;