Example #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));
     }
 }
Example #2
0
 public static IResult <T> tryTo <T>(Func <T> func)
 {
     try
     {
         return(func().Success());
     }
     catch (Exception exception)
     {
         return(MonadFunctions.failure <T>(exception));
     }
 }
Example #3
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));
     }
 }
Example #4
0
 public static IResult <Unit> tryTo(Action action)
 {
     try
     {
         action();
         return(Unit.Success());
     }
     catch (Exception exception)
     {
         return(MonadFunctions.failure <Unit>(exception));
     }
 }