コード例 #1
0
 public static PromiseOfTry <TResult> Bind <TInput, TResult>(
     this PromiseOfTry <TInput> promise,
     Func <TInput, PromiseOfTry <TResult> > f
     ) => () => promise.Run().Match(
     failure: ex => ex,
     success: t => f(t).Run()
     );
コード例 #2
0
 public static PromiseOfTry <TResult> Map <TInput, TResult>(
     this PromiseOfTry <TInput> promise,
     Func <TInput, TResult> map
     ) => () => promise.Run()
 .Match <Try <Exception, TResult> >(
     failure: exception => exception,
     success: r => map(r)
     );
コード例 #3
0
 public static Try <Exception, TResult> Run <TResult>(this PromiseOfTry <TResult> promise)
 {
     try
     {
         return(@promise());
     }
     catch (Exception e)
     {
         return(e);
     }
 }