/// <summary> evaluate will first compare the timestamp of the last fact in the fact
        /// array of the left and make sure the fact is still fresh. if it is not
        /// fresh, the method returns false.
        /// </summary>
        /// <param name="">leftlist
        /// </param>
        /// <param name="">right
        /// </param>
        /// <returns>
        ///
        /// </returns>
        public virtual bool evaluate(IFact[] leftlist, IFact right, long time)
        {
            bool eval = true;

            // first we compare the timestamp of the last fact in the
            // fact array. the last fact should be the fact with a
            // relative time window
            if (leftlist[leftlist.Length - 1].timeStamp() > time)
            {
                // we iterate over the binds and evaluate the facts
                for (int idx = 0; idx < binds.Length; idx++)
                {
                    // we got the binding
                    Binding bnd = binds[idx];
                    eval = bnd.evaluate(leftlist, right);
                    if (!eval)
                    {
                        break;
                    }
                }
                return(eval);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary> Method will use the right binding to perform the evaluation
        /// of the join. Since we are building joins similar to how
        /// CLIPS and other rule engines handle it, it means 95% of the
        /// time the right fact list only has 1 fact.
        /// </summary>
        /// <param name="">leftlist
        /// </param>
        /// <param name="">right
        /// </param>
        /// <returns>
        ///
        /// </returns>
        public virtual bool evaluate(IFact[] leftlist, IFact right)
        {
            bool eval = true;

            // we iterate over the binds and evaluate the facts
            for (int idx = 0; idx < binds.Length; idx++)
            {
                Binding bnd = binds[idx];
                eval = bnd.evaluate(leftlist, right);
                if (!eval)
                {
                    break;
                }
            }
            return(eval);
        }
示例#3
0
        /// <summary> Method will use the right binding to perform the evaluation
        /// of the join. Since we are building joins similar to how
        /// CLIPS and other rule engines handle it, it means 95% of the
        /// time the right fact list only has 1 fact.
        /// </summary>
        /// <param name="">leftlist
        /// </param>
        /// <param name="">right
        /// </param>
        /// <returns>
        ///
        /// </returns>
        public virtual bool evaluate(IFact[] leftlist, IFact right, Rete engine)
        {
            bool eval = true;

            // we iterate over the binds and evaluate the facts
            for (int idx = 0; idx < binds.Length; idx++)
            {
                Binding bnd = (Binding)binds[idx];
                if (bnd is Binding2)
                {
                    eval = ((Binding2)bnd).evaluate(leftlist, right, engine);
                }
                else
                {
                    eval = bnd.evaluate(leftlist, right);
                }
                if (!eval)
                {
                    break;
                }
            }
            return(eval);
        }