Exemplo n.º 1
0
 public Rule AddRule(Rule rule)
 {
   if (String.IsNullOrWhiteSpace(rule.Id))
     rule.Id = this.SystemName + "_" + Rules.Count.ToString();
   Rules.Add(rule);
   return rule;
 }
Exemplo n.º 2
0
 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;
   }
 }
Exemplo n.º 3
0
 internal RuleViolation(Rule appliedRule, ObjectInstance oi)
 {
   AppliedRule = appliedRule;
   InvalidObject = oi;
 }
Exemplo n.º 4
0
 public RuleViolationFromException(Rule appliedRule, ObjectInstance oi, Exception ex) : base(appliedRule, oi)
 {
   CaughtException = ex;
 }