示例#1
0
        public static Try <O> Map <T, O>(this Try <T> @try, Func <T, O> func)
        {
            if (func == null)
            {
                throw new ArgumentNullException(nameof(func));
            }

            Try <O> f = () => @try.Run().Match(t => Exceptional <O> .Return(func(t)), exception => Exceptional <O> .Return(exception));

            return(f);
        }
示例#2
0
 public static Exceptional <T> Run <T>(this Try <T> @try)
 {
     try
     {
         return(@try());
     }
     catch (Exception e)
     {
         return(Exceptional <T> .Return(e));
     }
 }
示例#3
0
 public static Try <T> AsTry <T>(this Func <T> func)
 {
     return(() => Exceptional <T> .Return(func()));
 }