public bool Select <TSelect>(Action <MemoryNode <TSelect> > callback) where TSelect : class { if (typeof(TSelect) == typeof(Tuple <T1, T2>) && _node == null) { _next.MatchJoinNode <T1>(t1 => { _next.MatchJoinNode <T2>(t2 => { _configurator.MatchOuterJoinNode(t1, t2, outerJoin => { // finally! _node = outerJoin; }); }); }); } var node = _node as MemoryNode <TSelect>; if (node != null) { callback(node); return(true); } return(false); }
public void Find(Action <OuterJoinNode <T1, T2> > callback) { if (_node == null) { OuterJoinNode <T1, T2> joinNode = _left.Successors .OfType <OuterJoinNode <T1, T2> >() .Where(node => _matchRight(node.RightActivation)) .FirstOrDefault(); if (joinNode != null) { _node = joinNode; } else { RightActivation <T2> rightActivation = _rightActivation(); _node = _configurator.Outer <T1, T2>(rightActivation); _left.AddActivation(_node); } } if (_node != null) { callback(_node); } }
public override bool Visit <TLeft, TRight>(OuterJoinNode <TLeft, TRight> node, Func <RuntimeVisitor, bool> next) { _current = _vertices.Get(node.Id, id => new Vertex(typeof(OuterJoinNode <,>), typeof(Tuple <TLeft, TRight>), typeof(TLeft).Tokens() + "," + typeof(TRight).Tokens())); if (_rightActivation == node.Id) { _edges.Add(new Edge(_current, _stack.Peek(), _current.TargetType.Name)); } else if (_stack.Count > 0) { _edges.Add(new Edge(_stack.Peek(), _current, _current.TargetType.Name)); } return(Next(node.RightActivation.Id, () => base.Visit(node, next))); }
public void Setup() { _called = null; var configurator = new OdoyuleRuntimeConfigurator(); var productionNode = new DelegateProductionNode <Tuple <A, B> >(16, (session, x) => _called = x); var constantNode = new ConstantNode <A>(42); JoinNode <A> joinNodeA = configurator.CreateNode(id => new JoinNode <A>(id, constantNode)); var constantNode2 = new ConstantNode <B>(27); JoinNode <B> joinNodeB = configurator.CreateNode(id => new JoinNode <B>(id, constantNode2)); OuterJoinNode <A, B> outerJoinNode = configurator.CreateNode(id => new OuterJoinNode <A, B>(id, joinNodeB)); outerJoinNode.AddActivation(productionNode); joinNodeA.AddActivation(outerJoinNode); var engine = new OdoyuleRulesEngine(configurator); AlphaNode <A> alphaNode = engine.GetAlphaNode <A>(); alphaNode.AddActivation(joinNodeA); AlphaNode <B> alphaNodeB = engine.GetAlphaNode <B>(); alphaNodeB.AddActivation(joinNodeB); using (Session session = engine.CreateSession()) { session.Add(new A()); session.Add(new B()); session.Run(); } }
public override bool Visit <TLeft, TRight>(OuterJoinNode <TLeft, TRight> node, Func <RuntimeVisitor, bool> next) { Append("OuterJoinNode[{0},{1}] => {2}", Tokens <TLeft>(), Tokens <TRight>(), Tokens <Tuple <TLeft, TRight> >()); return(Indent(next)); }
public virtual bool Visit <TLeft, TRight>(OuterJoinNode <TLeft, TRight> node, Func <RuntimeVisitor, bool> next) where TLeft : class where TRight : class { return(next(this)); }