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