Beispiel #1
0
 public virtual void resolveTemplates(Rete.Rete engine)
 {
     ICondition[] cnds = Conditions;
     for (int idx = 0; idx < cnds.Length; idx++)
     {
         ICondition cnd = cnds[idx];
         if (cnd is ObjectCondition)
         {
             ObjectCondition oc  = (ObjectCondition)cnd;
             Deftemplate     dft = (Deftemplate)engine.findTemplate(oc.TemplateName);
             if (dft != null)
             {
                 oc.Deftemplate = dft;
             }
         }
         else if (cnd is ExistCondition)
         {
             ExistCondition exc = (ExistCondition)cnd;
             Deftemplate    dft = (Deftemplate)engine.findTemplate(exc.TemplateName);
             if (dft != null)
             {
                 exc.Deftemplate = dft;
             }
         }
         else if (cnd is TemporalCondition)
         {
             TemporalCondition tempc = (TemporalCondition)cnd;
             Deftemplate       dft   = (Deftemplate)engine.findTemplate(tempc.TemplateName);
             if (dft != null)
             {
                 tempc.Deftemplate = dft;
             }
         }
     }
 }
Beispiel #2
0
        public static IList <Object> generateFacts(IRule rule, Rete.Rete engine)
        {
            List <Object> facts = new List <Object>();

            if (rule != null)
            {
                ICondition[] conditions = rule.Conditions;
                for (int idx = 0; idx < conditions.Length; idx++)
                {
                    ICondition c = conditions[idx];
                    if (c is ObjectCondition)
                    {
                        ObjectCondition oc  = (ObjectCondition)c;
                        Deftemplate     tpl = (Deftemplate)engine.findTemplate(oc.TemplateName);
                        if (tpl.ClassName != null)
                        {
                            Object data = generateJavaFacts(oc, tpl, engine);
                            facts.Add(data);
                        }
                        else
                        {
                            IFact data = generateDeffact(oc, tpl, engine);
                            facts.Add(data);
                        }
                    }
                    else if (c is TestCondition)
                    {
                    }
                }
            }
            return(facts);
        }