예제 #1
0
 protected bool Execute(Ruleset rs, Rule r)
 {
     log.Debug("Evaluating {0}.{1}", rs.Name, r.Id);
     if (r.When())
     {
         if (r.SideEffect != null)
         {
             r.SideEffect();
         }
         Rule r1 = rs.GetRule(r.TrueGoto);
         if (r1 != null)
         {
             log.Debug("Rule {0}.{1} true, checking exception {2}.{3}", rs.Name, r.Id, rs.Name, r1.Id);
             bool b = Execute(rs, r1);
             if (b)
             {
                 log.Debug("Exception {0}.{1} to rule {2}.{3} resulted in action - rule {2}.{3} not fired.", rs.Name, r1.Id, rs.Name, r.Id);
                 return true;
             }
         }
         log.Debug("Executing final action [{0}.{1}]", rs.Name,r.Id);
         if (r.Then != null)
         {
             r.Then();
         }
         return true;
     }
     else
     {
         log.Debug("Rule {0}.{1} is false", rs.Name, r.Id);
         Rule r2 = rs.GetRule(r.FalseGoto);
         if (r2 != null)
         {
             return Execute(rs, r2);
         }
         return false;
     }
 }