Esempio n. 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));
     }
 }
Esempio n. 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));
     }
 }
Esempio n. 3
0
 public static IResult <T> tryTo <T>(Func <T> func)
 {
     try
     {
         return(func().Success());
     }
     catch (Exception exception)
     {
         return(MonadFunctions.failure <T>(exception));
     }
 }
Esempio n. 4
0
 public static IResult <Unit> tryTo(Action action)
 {
     try
     {
         action();
         return(Unit.Success());
     }
     catch (Exception exception)
     {
         return(MonadFunctions.failure <Unit>(exception));
     }
 }
Esempio n. 5
0
 public Matching(Matched <T> matched)
 {
     this.matched = matched;
     action       = MonadFunctions.none <Func <TResult> >();
 }