public static void Is <E>(Expression <Func <bool> > condition) { if (!(condition.Compile().Invoke())) { string conditionString = new ConditionToEnglish().Translate(condition.Body); throw (Exception)Activator.CreateInstance(typeof(E), conditionString); } }
public static void Is <TException>(Expression <Func <bool> > condition) where TException : Exception { if (condition.Compile().Invoke()) { return; } var conditionString = ConditionToEnglish.Translate(condition.Body); throw (Exception)Activator.CreateInstance(typeof(TException), conditionString); }
public IsCondition <T> Check <TException>(Expression <Func <T, bool> > expression) where TException : Exception { if (!(expression.Compile().Invoke(_value))) { var conditionString = ConditionToEnglish.Translate(expression.Body, _name, _value); throw (Exception)Activator.CreateInstance(typeof(TException), conditionString); } return(this); }
public IsCondition <T> Check <E>(Expression <Func <T, bool> > expression) { if (!(expression.Compile().Invoke(_value))) { string conditionString = new ConditionToEnglish().Translate(expression.Body, _name, _value); throw (Exception)Activator.CreateInstance(typeof(E), conditionString); } return(this); }