示例#1
0
        public bool IsSatisfiedBy(IExecutionContext context, NodeDebugInfo nodeInfo, Fact fact)
        {
            var       factValue = fact.Object;
            Exception exception = null;
            bool      result    = false;

            try
            {
                result = _compiledExpression.Delegate(factValue);
                return(result);
            }
            catch (Exception e)
            {
                exception = e;
                bool isHandled = false;
                context.EventAggregator.RaiseLhsExpressionFailed(context.Session, e, _expression, factValue, null, fact, nodeInfo, ref isHandled);
                if (!isHandled)
                {
                    throw new RuleLhsExpressionEvaluationException("Failed to evaluate condition", _expression.ToString(), e);
                }
                return(false);
            }
            finally
            {
                context.EventAggregator.RaiseLhsExpressionEvaluated(context.Session, exception, _expression, factValue, result, null, fact, nodeInfo);
            }
        }
示例#2
0
        public object Invoke(AggregationContext context, ITuple tuple, IFact fact)
        {
            var args  = new object[_compiledExpression.ArrayArgumentCount];
            int index = tuple.Count - 1;

            foreach (var tupleFact in tuple.Facts)
            {
                IndexMap.SetElementAt(args, _factMap[index], tupleFact.Value);
                index--;
            }
            IndexMap.SetElementAt(args, _factMap[tuple.Count], fact.Value);

            Exception exception = null;
            object    result    = null;

            try
            {
                result = _compiledExpression.Delegate(args);
                return(result);
            }
            catch (Exception e)
            {
                exception = e;
                bool isHandled = false;
                context.EventAggregator.RaiseLhsExpressionFailed(context.Session, e, _expression, args, tuple, fact, context.NodeInfo, ref isHandled);
                throw new ExpressionEvaluationException(e, _expression, isHandled);
            }
            finally
            {
                context.EventAggregator.RaiseLhsExpressionEvaluated(context.Session, exception, _expression, args, result, tuple, fact, context.NodeInfo);
            }
        }
示例#3
0
        public bool IsSatisfiedBy(IExecutionContext context, Tuple leftTuple, Fact rightFact)
        {
            var args  = new object[_compiledExpression.ArrayArgumentCount];
            int index = leftTuple.Count - 1;

            foreach (var fact in leftTuple.Facts)
            {
                IndexMap.SetElementAt(args, _factIndexMap[index], fact.Object);
                index--;
            }
            IndexMap.SetElementAt(args, _factIndexMap[leftTuple.Count], rightFact.Object);

            try
            {
                return(_compiledExpression.Delegate(args));
            }
            catch (Exception e)
            {
                bool isHandled = false;
                context.EventAggregator.RaiseConditionFailed(context.Session, e, _expression, leftTuple, rightFact, ref isHandled);
                if (!isHandled)
                {
                    throw new RuleConditionEvaluationException("Failed to evaluate condition", _expression.ToString(), e);
                }
                return(false);
            }
        }
示例#4
0
 public bool IsSatisfiedBy(IExecutionContext context, Fact fact)
 {
     try
     {
         return(_compiledExpression.Delegate(new[] { fact.Object }));
     }
     catch (Exception e)
     {
         context.EventAggregator.RaiseConditionFailed(context.Session, e, _expression, null, fact);
         throw new RuleConditionEvaluationException("Failed to evaluate condition", _expression.ToString(), e);
     }
 }
示例#5
0
 public object Invoke(ITuple tuple, IFact fact)
 {
     try
     {
         var factValue = fact.Value;
         var result    = _compiledExpression.Delegate(factValue);
         return(result);
     }
     catch (Exception e)
     {
         throw new RuleExpressionEvaluationException("Failed to evaluate expression", _expression.ToString(), e);
     }
 }
示例#6
0
        public object Invoke(Tuple tuple)
        {
            var args  = new object[_compiledExpression.ArrayArgumentCount];
            int index = tuple.Count - 1;

            foreach (var fact in tuple.Facts)
            {
                IndexMap.SetElementAt(args, _factMap[index], fact.Object);
                index--;
            }

            return(_compiledExpression.Delegate(args));
        }
示例#7
0
 public object Invoke(ITuple tuple, IFact fact)
 {
     try
     {
         var factValue = fact.Value;
         var result    = _compiledExpression.Delegate(factValue);
         return(result);
     }
     catch (Exception e)
     {
         throw new AggregateExpressionException(e, _expression, tuple, fact);
     }
 }
示例#8
0
 public bool IsSatisfiedBy(IExecutionContext context, Fact fact)
 {
     try
     {
         return(_compiledExpression.Delegate(fact.Object));
     }
     catch (Exception e)
     {
         bool isHandled = false;
         context.EventAggregator.RaiseConditionFailed(context.Session, e, _expression, null, fact, ref isHandled);
         if (!isHandled)
         {
             throw new RuleConditionEvaluationException("Failed to evaluate condition", _expression.ToString(), e);
         }
         return(false);
     }
 }
示例#9
0
        public object Invoke(IExecutionContext context, Tuple tuple)
        {
            var args  = new object[_compiledExpression.ArrayArgumentCount];
            int index = tuple.Count - 1;

            foreach (var fact in tuple.Facts)
            {
                IndexMap.SetElementAt(args, _factIndexMap[index], fact.Object);
                index--;
            }

            try
            {
                return(_compiledExpression.Delegate(args));
            }
            catch (Exception e)
            {
                throw new RuleExpressionEvaluationException("Failed to evaluate binding expression", Expression.ToString(), e);
            }
        }
示例#10
0
        public object Invoke(ITuple tuple, IFact fact)
        {
            var args  = new object[_compiledExpression.ArrayArgumentCount];
            int index = tuple.Count - 1;

            foreach (var tupleFact in tuple.Facts)
            {
                IndexMap.SetElementAt(args, _factIndexMap[index], tupleFact.Value);
                index--;
            }
            IndexMap.SetElementAt(args, _factIndexMap[tuple.Count], fact.Value);

            try
            {
                var result = _compiledExpression.Delegate(args);
                return(result);
            }
            catch (Exception e)
            {
                throw new RuleExpressionEvaluationException("Failed to evaluate expression", _expression.ToString(), e);
            }
        }
示例#11
0
        public bool IsSatisfiedBy(IExecutionContext context, Tuple leftTuple, Fact rightFact)
        {
            var args  = new object[_compiledExpression.ParameterCount];
            int index = leftTuple.Count - 1;

            foreach (var fact in leftTuple.Facts)
            {
                FactIndexMap.SetElementAt(ref args, _conditionFactMap.Map(index), 0, fact.Object);
                index--;
            }
            FactIndexMap.SetElementAt(ref args, _conditionFactMap.Map(leftTuple.Count), 0, rightFact.Object);

            try
            {
                return(_compiledExpression.Delegate(args));
            }
            catch (Exception e)
            {
                context.EventAggregator.RaiseConditionFailed(context.Session, e, _expression, leftTuple, rightFact);
                throw new RuleConditionEvaluationException("Failed to evaluate condition", _expression.ToString(), e);
            }
        }
示例#12
0
        public object Invoke(AggregationContext context, ITuple tuple, IFact fact)
        {
            var       factValue = fact.Value;
            Exception exception = null;
            object    result    = null;

            try
            {
                result = _compiledExpression.Delegate(factValue);
                return(result);
            }
            catch (Exception e)
            {
                exception = e;
                bool isHandled = false;
                context.EventAggregator.RaiseLhsExpressionFailed(context.Session, e, _expression, factValue, tuple, fact, context.NodeInfo, ref isHandled);
                throw new ExpressionEvaluationException(e, _expression, isHandled);
            }
            finally
            {
                context.EventAggregator.RaiseLhsExpressionEvaluated(context.Session, exception, _expression, factValue, result, tuple, fact, context.NodeInfo);
            }
        }
示例#13
0
        public bool IsSatisfiedBy(IExecutionContext context, NodeDebugInfo nodeInfo, Tuple leftTuple, Fact rightFact)
        {
            var args  = new object[_compiledExpression.ArrayArgumentCount];
            int index = leftTuple.Count - 1;

            foreach (var fact in leftTuple.Facts)
            {
                IndexMap.SetElementAt(args, _factMap[index], fact.Object);
                index--;
            }
            IndexMap.SetElementAt(args, _factMap[leftTuple.Count], rightFact.Object);

            Exception exception = null;
            bool      result    = false;

            try
            {
                result = _compiledExpression.Delegate(args);
                return(result);
            }
            catch (Exception e)
            {
                exception = e;
                bool isHandled = false;
                context.EventAggregator.RaiseLhsExpressionFailed(context.Session, e, _expression, args, leftTuple, rightFact, nodeInfo, ref isHandled);
                if (!isHandled)
                {
                    throw new RuleLhsExpressionEvaluationException("Failed to evaluate condition", _expression.ToString(), e);
                }
                return(false);
            }
            finally
            {
                context.EventAggregator.RaiseLhsExpressionEvaluated(context.Session, exception, _expression, args, result, leftTuple, rightFact, nodeInfo);
            }
        }