コード例 #1
0
 public static IResult <T> assert <T>(bool test, Func <IResult <T> > ifTrue, string messageIfFalse)
 {
     try
     {
         return(test ? ifTrue() : messageIfFalse.Failure <T>());
     }
     catch (Exception exception)
     {
         return(MonadFunctions.failure <T>(exception));
     }
 }
コード例 #2
0
 public static IResult <T> assert <T>(Func <bool> test, Func <T> ifTrue, Func <string> messageIfFalse)
 {
     try
     {
         return(test() ? ifTrue().Success() : messageIfFalse().Failure <T>());
     }
     catch (Exception exception)
     {
         return(MonadFunctions.failure <T>(exception));
     }
 }
コード例 #3
0
 public static IResult <T> tryTo <T>(Func <T> func)
 {
     try
     {
         return(func().Success());
     }
     catch (Exception exception)
     {
         return(MonadFunctions.failure <T>(exception));
     }
 }
コード例 #4
0
 public static IResult <Unit> tryTo(Action action)
 {
     try
     {
         action();
         return(Unit.Success());
     }
     catch (Exception exception)
     {
         return(MonadFunctions.failure <Unit>(exception));
     }
 }
コード例 #5
0
 public Matching(Matched <T> matched)
 {
     this.matched = matched;
     action       = MonadFunctions.none <Func <TResult> >();
 }