public Rule AddRule(Rule rule) { if (String.IsNullOrWhiteSpace(rule.Id)) rule.Id = this.SystemName + "_" + Rules.Count.ToString(); Rules.Add(rule); return rule; }
public static Boolean CheckRuleIsValid(Rule ruleToEval, ObjectInstance oi, out RuleViolation violatedRule) { try { if (CheckCondition(ruleToEval.Condition, oi)) { if (ruleToEval.Assertion(oi) != true) { violatedRule = new RuleViolation(ruleToEval, oi); return false; } else { violatedRule = null; return true; } } violatedRule = null; return true; } catch(Exception ex) { violatedRule = new RuleViolationFromException(ruleToEval, oi, ex); return false; } }
internal RuleViolation(Rule appliedRule, ObjectInstance oi) { AppliedRule = appliedRule; InvalidObject = oi; }
public RuleViolationFromException(Rule appliedRule, ObjectInstance oi, Exception ex) : base(appliedRule, oi) { CaughtException = ex; }