private static Boolean CheckCondition(Func <ObjectInstance, Boolean> condition, ObjectInstance oi) { if (condition == null) { return(true); } else { try { return(condition(oi)); } //if the condition is dependent on another field which is also invalid, it will fail. catch (Exception ex) { //update - this is incomplete: We should find a way to save that this happened, let the rest of the validation continue, but then check to see if this condition exists an throw a real error if (Debugger.IsAttached) { Debug.WriteLine("Rule '{0}' not applied - condition invalid with exception:"); Debug.WriteLine(ex); } throw; } } }
internal RuleViolation(Rule appliedRule, ObjectInstance oi) { AppliedRule = appliedRule; InvalidObject = oi; }
public RuleViolationFromException(Rule appliedRule, ObjectInstance oi, Exception ex) : base(appliedRule, oi) { CaughtException = ex; }