public override void VisitAlphaNode <T>(LogContext context, IAlphaNode <T> node)
 {
     using (_log.BeginScope <AlphaNode <T> >())
     {
         base.VisitAlphaNode(context, node);
     }
 }
        public AlphaBuilderContext <T> BuildSelectionNode <T>(AlphaBuilderContext <T> context, Expression <Func <T, bool> > conditionExpression)
            where T : class
        {
            using (_logger.BeginScope($"{nameof(BuildSelectionNode)}<{typeof(T).Name}>"))
            {
                var alphaCondition = new AlphaCondition <T>(conditionExpression);

                _logger.LogDebug($"Condition: {alphaCondition}");

                IAlphaNode <T> alphaNode = context.CurrentNode;

                SelectionNode <T> selectionNode = alphaNode.GetChildNodes <SelectionNode <T> >()
                                                  .FirstOrDefault(x => x.Condition.Equals(alphaCondition));
                if (selectionNode == null)
                {
                    using (_logger.BeginScope("Create"))
                    {
                        _logger.LogDebug($"Creating selection node: {typeof(T).Name}");

                        selectionNode = new SelectionNode <T>(_loggerFactory, alphaCondition);
                        alphaNode.AddChild(selectionNode);
                    }
                }

                return(new RuntimeAlphaBuilderContext <T>(context.Declaration, selectionNode));
            }
        }
Exemple #3
0
        public virtual void VisitAlphaNode <T>(TContext context, IAlphaNode <T> node)
            where T : class
        {
            VisitAlphaMemoryNode(context, node.MemoryNode);

            foreach (var childNode in node.GetChildNodes <INode>())
            {
                childNode.Accept(this, context);
            }
        }
Exemple #4
0
        ConnectHandle IAlphaNode.AddChild <T>(IAlphaNode <T> node)
        {
            var alphaNode = node as IAlphaNode <TFact>;

            if (alphaNode == null)
            {
                throw new ArgumentException($"The node must match the fact type: {typeof(TFact).Name}", nameof(node));
            }

            return(_childNodes.Connect(alphaNode));
        }
        public override void VisitAlphaNode <T>(GraphContext context, IAlphaNode <T> node)
        {
            var nodeInfo = new Node(Interlocked.Increment(ref _id), node, typeof(T), "alpha");

            context.Add(nodeInfo);
            context.Link(nodeInfo, new Node(-1, node.MemoryNode, typeof(T), ""));

            foreach (var childNode in node.GetChildNodes <INode>())
            {
                context.Link(nodeInfo, new Node(-1, childNode, typeof(T), ""));
            }

            base.VisitAlphaNode(context, node);
        }
Exemple #6
0
 public RuntimeAlphaBuilderContext(FactDeclaration <T> declaration, IAlphaNode <T> currentNode)
 {
     Declaration   = declaration;
     CurrentNode   = currentNode;
     CurrentSource = currentNode.MemoryNode;
 }