コード例 #1
0
 public static ICanbe <I> Reinit <I>(this ICanbe <I> self, Func <I> def)
 {
     try
     {
         if (self.IsError)
         {
             return(Cons <I>(def()));
         }
         return(self);
     }
     catch (Exception exn) { return(Fail <I>(Error.From(exn))); }
 }
コード例 #2
0
 public static ICanbe <I> FailIf <I>(this ICanbe <I> self, Func <I, bool> func, string message, int errorcode = 0)
 {
     try
     {
         if (self.IsOk && func(self.Value))
         {
             return(Fail <I>(message, errorcode));
         }
         return(self);
     }
     catch (Exception exn) { return(Fail <I>(Error.From(exn))); }
 }
コード例 #3
0
 public static ICanbe <I> OnSucc <I>(this ICanbe <I> self, Action <I> func)
 {
     try
     {
         if (self.IsOk)
         {
             func(self.Value);
         }
         return(self);
     }
     catch (Exception exn) { return(Fail <I>(Error.From(exn))); }
 }
コード例 #4
0
 public static ICanbe <I> OnFail <I>(this ICanbe <I> self, Action <Error> func)
 {
     try
     {
         if (self.IsError)
         {
             func(self.Error);
         }
         return(self);
     }
     catch (Exception exn) { return(Fail <I>(Error.From(exn))); }
 }
コード例 #5
0
 public static ICanbe <O> Map <I, O>(this ICanbe <I> self, Func <I, O> func)
 => self.Bind(x => Cons(func(x)));
コード例 #6
0
 async public static Task <ICanbe <O> > Bind <I, O>(this ICanbe <I> self, Func <I, Task <ICanbe <O> > > func)
 {
     try { return(self.IsError ? Fail <O>(self.Error) : await func(self.Value)); }
     catch (Exception exn) { return(Fail <O>(Error.From(exn))); }
 }
コード例 #7
0
 public static ICanbe <I[]> FailOnEmpty <I>(this ICanbe <I[]> self, Func <I[], string> lazymessage, System.Net.HttpStatusCode code)
 => FailIf(self, (xs => xs == null || (!xs.Any())), lazymessage, (int)code);
コード例 #8
0
 public static ICanbe <I[]> FailOnEmpty <I>(this ICanbe <I[]> self, string message, System.Net.HttpStatusCode code)
 => FailOnEmpty(self, message, (int)code);
コード例 #9
0
 public static ICanbe <I[]> FailOnEmpty <I>(this ICanbe <I[]> self, string message, int code = 0)
 => self.FailIf(xs => xs == null || (!xs.Any()), message, code);
コード例 #10
0
 public static ICanbe <I> FailOnNull <I>(this ICanbe <I> self, Func <I, string> lazymessage, System.Net.HttpStatusCode code)
 => FailIf(self, (xs => xs == null), lazymessage, (int)code);
コード例 #11
0
 public static ICanbe <I> FailOnNull <I>(this ICanbe <I> self, string message, System.Net.HttpStatusCode code)
 => FailOnNull(self, message, (int)code);
コード例 #12
0
 public static ICanbe <I> FailOnNull <I>(this ICanbe <I> self, string message, int code = 0)
 => self.FailIf(xs => xs == null, message, code);
コード例 #13
0
 public static ICanbe <I> FailIf <I>(this ICanbe <I> self, Func <I, bool> func, Func <I, string> lazymessage, System.Net.HttpStatusCode errorcode)
 => FailIf <I>(self, func, lazymessage, (int)errorcode);
コード例 #14
0
 async public static Task <ICanbe <O> > Map <I, O>(this ICanbe <I> self, Func <I, Task <O> > func)
 => await self.Bind(async x => Cons(await func(x)));