示例#1
0
        /// <summary>
        /// Called when [join node] is visited.
        /// </summary>
        /// <param name="node">The node.</param>
        public override void OnJoinNode(JoinNode node)
        {
            _sb.Append(_indentString).Append("Join Node <---------- ");
            node.AlphaMemory.Accept(this);

            if (node.IsHeadOfSubNetwork)
            {
                _sb.Append("").AppendLine("  |");
                _indentString = "  |            ";
                _sb.Append("  |--------> ").AppendLine("SUBNETWORK");
                _sb.Append(_indentString).AppendLine("  |");
                _sb.Append(_indentString).AppendLine("  V");
                foreach (ReteNode child in node.Children)
                {
                    if ((child is NCCNode) == false)
                    {
                        child.Accept(this);
                    }
                }
            }
            else
            {
                _sb.Append(_indentString).AppendLine("  |");
                _sb.Append(_indentString).AppendLine("  V");
                foreach (ReteNode child in node.Children)
                {
                    child.Accept(this);
                }
            }
        }
示例#2
0
        public void Visit(JoinNode node)
        {
            SetQueryPart(QueryPart.From);
            var joins = new Stack <JoinNode>();

            var join = node;

            while (join != null)
            {
                joins.Push(join);
                join = join.Source as JoinNode;
            }

            join = joins.Pop();
            join.Source.Accept(this);
            join.With.Accept(this);

            join.Expression.Accept(this);
            join.Accept(_visitor);

            while (joins.Count > 0)
            {
                join = joins.Pop();
                join.With.Accept(this);

                join.Expression.Accept(this);
                join.Accept(_visitor);
            }
        }
示例#3
0
        public void Find(Action <JoinNode <T> > callback)
        {
            if (_node == null)
            {
                var joinNode = _left.Successors
                               .OfType <JoinNode <T> >()
                               .Where(node => _matchRight(node.RightActivation))
                               .FirstOrDefault();

                if (joinNode != null)
                {
                    _node = joinNode;
                }
                else
                {
                    var rightActivation = _rightActivation();
                    _node = _configurator.Join(rightActivation);
                    _left.AddActivation(_node);
                }
            }

            if (_node != null)
            {
                callback(_node);
            }
        }
示例#4
0
        public async Task Should_properly_handle_activation()
        {
            ITupleSource <Member> leftSource = new TestTupleSource <Member>(new Tuple <Member>(new Member()
            {
                MemberId = 27, Name = "Frank"
            }));

            IFactSource <Address> rightSource = new TestFactSource <Address>();

            var testSink = new TestTupleSink <Address>();

            IBetaNode <Member, Address> betaNode = new JoinNode <Member, Address>(leftSource, rightSource,
                                                                                  new BetaCondition <Member, Address>((m, a) => true));

            betaNode.Connect(testSink);

            var sessionContext = new TestSession();
            var factContext    = new TestFactContext <Address>(sessionContext, new Address()
            {
                MemberId = 42, PostalCode = "68106"
            });

            await betaNode.Insert(factContext);

            Assert.That(testSink.Tuples.Count(), Is.EqualTo(1));
        }
示例#5
0
        public void FirstTestName()
        {
            var route = new RouteNode <Uri>(new StubRoute <Uri>());

            var joinNode = new JoinNode <Uri>(_id++, new ConstantNode <Uri>());

            joinNode.Add(route);

            var alpha = new AlphaNode <Uri>(_id++);

            alpha.Add(joinNode);

            var equal = new EqualNode <Uri>(() => _id++);

            equal.Add("version", alpha);

            var segment = new SegmentNode <Uri>(1);

            segment.Add(equal);

            var engine = new MagnumRoutingEngine <Uri>(x => x);

            engine.Match <RootNode <Uri> >().Single().Add(segment);

            bool called = false;

            var uri = new Uri("http://localhost/version");

            engine.Route(uri, x =>
            {
                called = true;
            });

            called.ShouldBeTrue();
        }
示例#6
0
        public async Task Should_handle_inverse_activation()
        {
            ITupleSource <Member> leftSource = new TestTupleSource <Member>();

            IFactSource <Address> rightSource = new TestFactSource <Address>(
                new Address()
            {
                MemberId = 27, PostalCode = "68106"
            },
                new Address()
            {
                MemberId = 27, PostalCode = "74011"
            },
                new Address()
            {
                MemberId = 42, PostalCode = "74011"
            });

            var testSink = new TestTupleSink <Address>();

            IBetaNode <Member, Address> betaNode = new JoinNode <Member, Address>(leftSource, rightSource,
                                                                                  new BetaCondition <Member, Address>((m, a) => m.Right.MemberId == a.MemberId));

            betaNode.Connect(testSink);

            var sessionContext = new TestSession();
            var tupleContext   = new TestTupleContext <Member>(sessionContext, new Member {
                MemberId = 27, Name = "Frank"
            });

            await betaNode.Insert(tupleContext);

            Assert.That(testSink.Tuples.Count(), Is.EqualTo(2));
        }
 private void RemovePrefix(JoinNode node, string prefix)
 {
     if (!string.IsNullOrEmpty(prefix))
     {
         RemovePrefix(node, prefix, new Dictionary <DBTable, DBTable>());
     }
 }
示例#8
0
        public static JoinNode <T> CreateJunction <T>(this IEnumerable <AlphaNode <T> > nodes, RightActivation <T> rightActivation)
        {
            var junction = new JoinNode <T>(rightActivation);

//			junction.AddSuccessor(nodes.CreateJunction());
            throw new NotImplementedException();
        }
示例#9
0
		public void FirstTestName()
		{
			var route = new RouteNode<Uri>(new StubRoute<Uri>());

			var joinNode = new JoinNode<Uri>(_id++, new ConstantNode<Uri>());
			joinNode.Add(route);

			var alpha = new AlphaNode<Uri>(_id++);
			alpha.Add(joinNode);

			var equal = new EqualNode<Uri>(() => _id++);
			equal.Add("version", alpha);

			var segment = new SegmentNode<Uri>(1);
			segment.Add(equal);

			var engine = new MagnumRoutingEngine<Uri>(x => x);
			engine.Match<RootNode<Uri>>().Single().Add(segment);

			bool called = false;

			var uri = new Uri("http://localhost/version");
			engine.Route(uri, x =>
				{
					called = true;
				});

			called.ShouldBeTrue();
		}
示例#10
0
        private (CfgNode, CfgNode) CreateBranchConditionNodes(ProgramState state,
                                                              Expression trueNodeCondition,
                                                              Expression falseNodeCondition)
        {
            var truePruneNode = new PruneNode(state.CurrentLocation,
                                              true,
                                              PruneNode.PruneNodeKind.MethodBody,
                                              Prune.IfKind.Ik_if,
                                              state.ProcDesc);

            var falsePruneNode = new PruneNode(state.CurrentLocation,
                                               false,
                                               PruneNode.PruneNodeKind.MethodBody,
                                               Prune.IfKind.Ik_if,
                                               state.ProcDesc);

            truePruneNode.Instructions.Add(new Prune(trueNodeCondition,
                                                     true,
                                                     Prune.IfKind.Ik_if,
                                                     state.CurrentLocation));
            falsePruneNode.Instructions.Add(new Prune(falseNodeCondition,
                                                      false,
                                                      Prune.IfKind.Ik_if,
                                                      state.CurrentLocation));

            if (HasLoops(state.CurrentInstruction))
            {
                var joinNode = new JoinNode(state.CurrentLocation, state.ProcDesc);
                RegisterNode(state, joinNode);
                state.PreviousNode = joinNode;
            }

            return(truePruneNode, falsePruneNode);
        }
        protected override bool Visit <T>(JoinNode <T> node)
        {
            _current = GetVertex(node.GetHashCode(), () => "J", typeof(JoinNode <>), typeof(T));

            LinkFromParent();

            return(WithVertex(() => base.Visit(node)));
        }
示例#12
0
        internal static ReteNode Create(JoinNode node)
        {
            var conditions = node.ExpressionElements.Select(c =>
                                                            new KeyValuePair <string, LambdaExpression>("Condition", c.Expression));

            return(new ReteNode(node.Id, NodeType.Join, expressions: conditions,
                                rules: node.NodeInfo.Rules));
        }
示例#13
0
        public void Visit(JoinNode node)
        {
            var expression  = Nodes.Pop();
            var joinedTable = (FromNode)Nodes.Pop();
            var source      = (FromNode)Nodes.Pop();

            Nodes.Push(new JoinNode(source, joinedTable, expression, node.JoinType));
        }
示例#14
0
 protected internal override void VisitJoinNode(SnapshotBuilder builder, JoinNode node)
 {
     if (builder.IsVisited(node))
     {
         return;
     }
     builder.AddNode(node, NodeInfo.Create);
     base.VisitJoinNode(builder, node);
 }
        public override void VisitJoinNode <TLeft, TRight>(GraphContext context, JoinNode <TLeft, TRight> node)
        {
            var nodeInfo = new Node(Interlocked.Increment(ref _id), node, typeof(TRight), "join");

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

            base.VisitJoinNode(context, node);
        }
示例#16
0
 protected internal override void VisitJoinNode(SchemaBuilder builder, JoinNode node)
 {
     if (builder.IsVisited(node))
     {
         return;
     }
     builder.AddNode(node, ReteNode.Create);
     base.VisitJoinNode(builder, node);
 }
示例#17
0
        void Bind(Action <JoinNode <T> > callback)
        {
            if (_join == null)
            {
                _join = new JoinNode <T>(new ConstantNode <T>());
                _alphaNode.AddActivation(_join);
            }

            callback(_join);
        }
示例#18
0
        public void Only_those_that_are_matched_should_be_called()
        {
            var junction = new JoinNode <Customer>(_constantNode);

            junction.AddSuccessor(_actionNode);

            var alphaNodeA = new AlphaNode <Customer>();

            alphaNodeA.AddSuccessor(junction);

            var joinJunction = new JoinNode <Customer>(alphaNodeA);

            var alphaNodeB = new AlphaNode <Customer>();

            alphaNodeB.AddSuccessor(joinJunction);

            var actionNode = new ActionNode <Customer>(x => _secondaryCalled.Complete(x.Element.Object));

            var joinJunction2 = new JoinNode <Customer>(alphaNodeA);

            joinJunction2.AddSuccessor(actionNode);

            var alphaNodeC = new AlphaNode <Customer>();

            alphaNodeC.AddSuccessor(joinJunction2);

            var tree = new TypeNode <Customer>();

            var isPreferred = new ConditionNode <Customer>(x => x.Preferred);

            isPreferred.AddSuccessor(alphaNodeA);

            tree.AddSuccessor(isPreferred);

            tree.AddSuccessor(alphaNodeB);

            var isActive = new ConditionNode <Customer>(x => x.Active);

            isActive.AddSuccessor(alphaNodeC);
            tree.AddSuccessor(isActive);

            var visitor = new StringNodeVisitor();

            tree.Visit(visitor);

            Trace.WriteLine(visitor.Result);



            tree.Activate(_context);
            _session.Run();

            _primaryCalled.IsCompleted.ShouldBeTrue();
            _secondaryCalled.IsCompleted.ShouldBeFalse();
        }
 protected virtual bool Visit <T>(JoinNode <T> node)
 {
     IncreaseDepth();
     if (node.RightActivation as ConstantNode <T> != null)
     {
         Visit(node.RightActivation);
     }
     node.Activations.Each(activation => Visit(activation));
     DecreaseDepth();
     return(true);
 }
示例#20
0
		public void FirstTestName()
		{
			var junction = new JoinNode<Customer>(_constantNode);
			junction.AddSuccessor(_actionNode);

			var memoryA = new BetaMemory<Customer>(junction);

			memoryA.Activate(_context);

			_agenda.Execute();

			_context.VerifyAllExpectations();
		}
示例#21
0
        public void FirstTestName()
        {
            var junction = new JoinNode<Customer>(_constantNode);
            junction.AddSuccessor(_actionNode);

            var memoryA = new BetaMemory<Customer>(junction);

            memoryA.Activate(_context);

            _session.Run();

            _primaryCalled.IsCompleted.ShouldBeTrue();
        }
        object FindJoinNode <T>()
        {
            JoinNode <T> result = null;

            new MatchAlphaNode <T>(_engine,
                                   alphaNode => { new MatchJoinNode <T>(alphaNode, joinNode => { result = joinNode; }); });

            if (result == null)
            {
                throw new InvalidOperationException("Failed to create join node: " + typeof(T).ToShortTypeName());
            }

            return(result.BetaMemory);
        }
示例#23
0
        public void FirstTestName()
        {
            var junction = new JoinNode <Customer>(_constantNode);

            junction.AddSuccessor(_actionNode);

            var memoryA = new BetaMemory <Customer>(junction);

            memoryA.Activate(_context);

            _agenda.Execute();

            _context.VerifyAllExpectations();
        }
示例#24
0
        public void FirstTestName()
        {
            var junction = new JoinNode <Customer>(_constantNode);

            junction.AddSuccessor(_actionNode);

            var memoryA = new BetaMemory <Customer>(junction);

            memoryA.Activate(_context);

            _session.Run();

            _primaryCalled.IsCompleted.ShouldBeTrue();
        }
示例#25
0
        public void One_more_level_of_indirection()
        {
            var junction = new JoinNode<Customer>(_constantNode);
            junction.AddSuccessor(_actionNode);

            var alphaNode = new AlphaNode<Customer>();
            alphaNode.AddSuccessor(junction);

            alphaNode.Activate(_context);

            _session.Run();

            _primaryCalled.IsCompleted.ShouldBeTrue();
        }
        public void Visit(JoinNode node)
        {
            var expression = Nodes.Pop();
            var fromNode   = (FromNode)Nodes.Pop();

            if (node is OuterJoinNode outerJoin)
            {
                Nodes.Push(new OuterJoinNode(outerJoin.Type, fromNode, expression));
            }
            else
            {
                Nodes.Push(new InnerJoinNode(fromNode, expression));
            }
        }
		public void AddRoutes(IEnumerable<string> paths)
		{
			foreach (string path in paths)
			{
				var route = new RouteNode<Uri>(new StubRoute<Uri>());

				var joinNode = new JoinNode<Uri>(_id++, new ConstantNode<Uri>());
				joinNode.Add(route);

				var alpha = new AlphaNode<Uri>(_id++);
				alpha.Add(joinNode);

				_equal.Add(path.Substring(1), alpha);
			}
		}
        public override bool Visit <T>(JoinNode <T> node, Func <RuntimeVisitor, bool> next)
        {
            _current = _vertices.Get(node.Id, id => new Vertex(typeof(JoinNode <>), typeof(T), typeof(T).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)));
        }
示例#29
0
        public BetaBuilderContext <T, T> BuildJoinNode <T>(AlphaBuilderContext <T> context)
            where T : class
        {
            using (_logger.BeginScope($"{nameof(BuildJoinNode)}<{typeof(T).Name}>"))
            {
                var betaSource  = new DummyNode <T>() as ITupleSource <T>;
                var alphaSource = context.CurrentSource as IFactSource <T>;

                _logger.LogDebug($"Creating join node: {typeof(T).Name}");

                var node = new JoinNode <T, T>(betaSource, alphaSource, new BetaCondition <T, T>((x, y) => true));

                return(new RuntimeBetaBuilderContext <T, T>(context.Declaration, node));
            }
        }
示例#30
0
        public void AddRoutes(IEnumerable <string> paths)
        {
            foreach (string path in paths)
            {
                var route = new RouteNode <Uri>(new StubRoute <Uri>());

                var joinNode = new JoinNode <Uri>(_id++, new ConstantNode <Uri>());
                joinNode.Add(route);

                var alpha = new AlphaNode <Uri>(_id++);
                alpha.Add(joinNode);

                _equal.Add(path.Substring(1), alpha);
            }
        }
示例#31
0
        public void One_more_level_of_indirection()
        {
            var junction = new JoinNode <Customer>(_constantNode);

            junction.AddSuccessor(_actionNode);

            var alphaNode = new AlphaNode <Customer>();

            alphaNode.AddSuccessor(junction);

            alphaNode.Activate(_context);

            _session.Run();

            _primaryCalled.IsCompleted.ShouldBeTrue();
        }
示例#32
0
        protected override bool Visit <TChannel>(JoinNode <TChannel> node)
        {
            var match = node as JoinNode <T>;

            if (match != null)
            {
                var constant = match.RightActivation as ConstantNode <T>;
                if (constant != null)
                {
                    _join = match;
                    return(false);
                }
            }

            return(base.Visit(node));
        }
 private void RemovePrefix(JoinNode node, string prefix, Dictionary <DBTable, DBTable> clonedTables)
 {
     if (node.Table.Name.StartsWith(prefix, StringComparison.Ordinal))
     {
         DBTable cloned;
         if (!clonedTables.TryGetValue(node.Table, out cloned))
         {
             cloned = RemovePrefix(node.Table, prefix);
             clonedTables[node.Table] = cloned;
             node.Table = cloned;
         }
     }
     foreach (var subNode in node.SubNodes)
     {
         RemovePrefix(subNode, prefix, clonedTables);
     }
 }
示例#34
0
        public void Only_those_that_are_matched_should_be_called()
        {
            var junction = new JoinNode<Customer>(_constantNode);
            junction.AddSuccessor(_actionNode);

            var alphaNodeA = new AlphaNode<Customer>();
            alphaNodeA.AddSuccessor(junction);

            var joinJunction = new JoinNode<Customer>(alphaNodeA);

            var alphaNodeB = new AlphaNode<Customer>();
            alphaNodeB.AddSuccessor(joinJunction);

            var actionNode = new ActionNode<Customer>(x => _secondaryCalled.Complete(x.Element.Object));

            var joinJunction2 = new JoinNode<Customer>(alphaNodeA);
            joinJunction2.AddSuccessor(actionNode);

            var alphaNodeC = new AlphaNode<Customer>();
            alphaNodeC.AddSuccessor(joinJunction2);

            var tree = new TypeNode<Customer>();

            var isPreferred = new ConditionNode<Customer>(x => x.Preferred);
            isPreferred.AddSuccessor(alphaNodeA);

            tree.AddSuccessor(isPreferred);

            tree.AddSuccessor(alphaNodeB);

            var isActive = new ConditionNode<Customer>(x => x.Active);
            isActive.AddSuccessor(alphaNodeC);
            tree.AddSuccessor(isActive);

            var visitor = new StringNodeVisitor();
            tree.Visit(visitor);

            Trace.WriteLine(visitor.Result);

            tree.Activate(_context);
            _session.Run();

            _primaryCalled.IsCompleted.ShouldBeTrue();
            _secondaryCalled.IsCompleted.ShouldBeFalse();
        }
示例#35
0
		public void Pulling_an_element_through_two_memories_should_merge_properly()
		{
			var junction = new JoinNode<Customer>(_constantNode);
			junction.AddSuccessor(_actionNode);

			var memoryB = new BetaMemory<Customer>(junction);

			var joinJunction = new JoinNode<Customer>(memoryB);

			var memoryA = new BetaMemory<Customer>(joinJunction);

			memoryA.Activate(_context);
			memoryB.Activate(_context);

			_agenda.Execute();

			_context.VerifyAllExpectations();
		}
示例#36
0
        public IBetaNode <T, T> BuildJoinNode <T>(BuilderContext context)
            where T : class
        {
            using (_logger.BeginScope($"{nameof(BuildJoinNode)}<{typeof(T).Name}>"))
            {
                var betaSource  = (context.BetaSource ?? new DummyNode <T>()) as ITupleSource <T>;
                var alphaSource = context.AlphaSource as IFactSource <T>;

                _logger.LogDebug($"Creating join node: {typeof(T).Name}");

                var node = new JoinNode <T, T>(betaSource, alphaSource, new BetaCondition <T, T>((x, y) => true));

                context.BetaSource = node.MemoryNode;

                context.ClearAlphaSource();

                return(node);
            }
        }
示例#37
0
        public void Pulling_an_element_through_two_memories_should_merge_properly()
        {
            var junction = new JoinNode <Customer>(_constantNode);

            junction.AddSuccessor(_actionNode);

            var memoryB = new BetaMemory <Customer>(junction);

            var joinJunction = new JoinNode <Customer>(memoryB);

            var memoryA = new BetaMemory <Customer>(joinJunction);

            memoryA.Activate(_context);
            memoryB.Activate(_context);

            _agenda.Execute();

            _context.VerifyAllExpectations();
        }
示例#38
0
        public void Setup()
        {
            _called = null;

            var productionNode = new DelegateProductionNode<A>(16, (session,x) => _called = x);

            var constantNode = new ConstantNode<A>(42);

            var joinNode = new JoinNode<A>(69, constantNode);
            joinNode.AddActivation(productionNode);

            var engine = new OdoyuleRulesEngine(new OdoyuleRuntimeConfigurator());

            AlphaNode<A> alphaNode = engine.GetAlphaNode<A>();
            alphaNode.AddActivation(joinNode);

            using (Session session = engine.CreateSession())
            {
                session.Add(new A());
                session.Run();
            }
        }
        /// <summary>
        /// Called when [join node] is visited.
        /// </summary>
        /// <param name="node">The node.</param>
        public override void OnJoinNode(JoinNode node)
        {
            _sb.Append(_indentString).Append("Join Node <---------- ");
            node.AlphaMemory.Accept(this);

            if (node.IsHeadOfSubNetwork)
            {
                _sb.Append("").AppendLine("  |");
                _indentString = "  |            ";
                _sb.Append("  |--------> ").AppendLine("SUBNETWORK");
                _sb.Append(_indentString).AppendLine("  |");
                _sb.Append(_indentString).AppendLine("  V");
                foreach (ReteNode child in node.Children)
                {
                    if ((child is NCCNode) == false)
                        child.Accept(this);
                }
            }
            else
            {
                _sb.Append(_indentString).AppendLine("  |");
                _sb.Append(_indentString).AppendLine("  V");
                foreach (ReteNode child in node.Children)
                {
                    child.Accept(this);
                }
            }
        }
示例#40
0
 private void traceStatement(JoinNode statement, string methodName)
 {
     Tracing.Tracer.LogVerboseSubSeparator("Filter DataStore -- "+ methodName);
     Tracing.Tracer.LogVerboseValue("statement.TableName", statement.TableName);
     Tracing.Tracer.LogVerboseValue("statement", statement);
     Tracing.Tracer.LogVerboseValue("FilterProviderManager.Providers.Count", FilterProviderManager.Providers.Count);
 }
示例#41
0
        public void Pulling_an_element_through_two_memories_should_merge_properly()
        {
            var junction = new JoinNode<Customer>(_constantNode);
            junction.AddSuccessor(_actionNode);

            var alphaNodeA = new AlphaNode<Customer>();
            alphaNodeA.AddSuccessor(junction);

            var joinJunction = new JoinNode<Customer>(alphaNodeA);

            var alphaNodeB = new AlphaNode<Customer>();
            alphaNodeB.AddSuccessor(joinJunction);

            alphaNodeA.Activate(_context);
            alphaNodeB.Activate(_context);

            _session.Run();
        }
示例#42
0
 internal static NodeInfo Create(JoinNode node)
 {
     return new NodeInfo(NodeType.Join, string.Empty, node.Conditions.Select(c => c.ToString()), Empty, Empty);
 }
 private void Process(JoinNode node)
 {
     if (node == null) return;
     node.Alias = ProcessAlias(node.Alias);
     Process(node.Condition);
     if (node.SubNodes != null)
         foreach (JoinNode sub in node.SubNodes)
             Process(sub);
 }
示例#44
0
 /// <summary>
 /// Called when [join node] is visited.
 /// </summary>
 /// <param name="node">The node.</param>
 public virtual void OnJoinNode(JoinNode node)
 {
 }
 private void CollectTables(JoinNode node)
 {
     string alias = node.Alias ?? string.Empty;
     if (!tables.ContainsKey(alias))
     {
         DBTableEx table = XPDictionaryInformer.TranslateAndGet(node.TableName);
         if (table != null && table.IsCustom)
         {
             DBTableEx table2 = table.CustomPersistent.GetTable(dataStore);
             tables.Add(alias, new Tuple<DBTableEx, DBTableEx>(table, table2));
         }
     }
     if (node.SubNodes != null)
         foreach (JoinNode subNode in node.SubNodes)
             CollectTables(subNode);
 }
示例#46
0
 private List<JoinNode> JoinTags(string sql, string joinClause)
 {
     var joinTags = new List<JoinNode>();
     var startIndex = 0;
     var fromIndex = sql.IndexOf(joinClause, startIndex, StringComparison.InvariantCultureIgnoreCase);
     while (fromIndex > 0)
     {
         var joinNode = new JoinNode();
         joinNode.Position = fromIndex;
         joinNode.Name = joinClause;
         joinTags.Add(joinNode);
         startIndex = fromIndex + 1;
         fromIndex = sql.IndexOf(joinClause, startIndex, StringComparison.InvariantCultureIgnoreCase);
     }
     return joinTags;
 }
 private void Process(JoinNode node)
 {
     if (node == null) return;
     string alias = node.Alias ?? string.Empty;
     if (tables.ContainsKey(alias))
     {
         Tuple<DBTableEx, DBTableEx> replace = tables[alias];
         node.TableName = replace.Item2.Name;
     }
     Process(node.Condition);
     if (node.SubNodes != null)
         foreach (JoinNode sub in node.SubNodes)
             Process(sub);
 }
 private void AppendJoinNode(JoinNode node, StringBuilder joins)
 {
     if (formatter.BraceJoin)
         joins.Insert(0, "(");
     joins.Append("\n ");
     joins.Append(node.Type == JoinType.Inner ? "inner" : "left");
     joins.Append(" join ");
     joins.Append(GetTableOrView(node));
     joins.Append(" on ");
     joins.Append(Process(node.Condition));
     if (formatter.BraceJoin)
         joins.Append(')');
     foreach (JoinNode subNode in node.SubNodes)
         AppendJoinNode(subNode, joins);
 }
 private string GetTableOrView(JoinNode node)
 {
     string nodeName = translateNames ? XPDictionaryInformer.TranslateTableName(node.TableName) : node.TableName;
     bool isCustom = customAliases != null && customAliases.Contains(node.Alias ?? string.Empty);
     if (isCustom) return formatterSequred.FormatCustomTable(nodeName, node.Alias);
     string nodeSchema = formatter.ComposeSafeSchemaName(nodeName);
     string nodeTable = formatter.ComposeSafeTableName(nodeName);
     return secured ?
         formatterSequred.FormatView(nodeSchema, nodeTable, node.Alias) :
         formatterSequred.FormatTable(nodeSchema, nodeTable, node.Alias);
 }