Пример #1
0
        public TypeDispatchNode Add(TypeDispatchNode root, RuleDeclaration declaration)
        {
            ConditionDeclaration[] conditions  = declaration.Conditions.ToArray();
            Expression[]           expressions = conditions.Select(x => _normalizer.Normalize(x.Expression)).ToArray();

            var visitor = new FindConditionVisitor(expressions);

            root.Visit(visitor);

            object[] conditionNodes = visitor.ExistingNodes;

            for (int i = 0; i < conditions.Length; i++)
            {
                if (conditionNodes[i] == null)
                {
                    conditionNodes[i] = CreateConditionNode(root, conditions[i].MatchType, expressions[i]);
                }
            }

            Node joinNode = CreateJoinNode(conditionNodes, conditions[0].MatchType);

            declaration.Consequences.Each(consequence =>
            {
                CreateActionNode(joinNode, consequence.Expression);
            });

            return(root);
        }
Пример #2
0
        private Node CreateConditionNodeOfT <T>(TypeDispatchNode root, Expression <Func <T, bool> > expression)
        {
            var conditionNode = new ConditionNode <T>(expression);

            root.Add(conditionNode);

            return(conditionNode);
        }
Пример #3
0
        protected bool Visit(TypeDispatchNode node)
        {
            _lastNodeVertex = GetSink(node.GetHashCode(), () => "Rules", typeof(TypeDispatchNode), typeof(object));

            if (_stack.Count > 0)
            {
                _edges.Add(new Edge(_stack.Peek(), _lastNodeVertex, _lastNodeVertex.TargetType.Name));
            }

            return(true);
        }
Пример #4
0
 private Node CreateConditionNode(TypeDispatchNode root, Type matchType, Expression expression)
 {
     return(this.FastInvoke <DeclarationCompiler, Node>(new[] { matchType }, "CreateConditionNodeOfT", root, expression));
 }
Пример #5
0
        protected bool Visit(TypeDispatchNode node)
        {
            Append("MatchType");

            return(true);
        }