Exemple #1
0
        private NamespaceNodeInfo FindServiceNode(IEnumerable <string> urlTokens, bool fCreate = false)
        {
            if (urlTokens == null || !urlTokens.Any())
            {
                return(_rootNode);
            }

            var tokens = new List <string>(urlTokens);

            var node = _rootNode;

            while (tokens.Count > 0)
            {
                var search = tokens[0].ToLowerInvariant();
                if (string.IsNullOrEmpty(search))
                {
                    tokens.RemoveAt(0);
                    continue;
                }

                if (node.Children.ContainsKey(search))
                {
                    node = node.Children[search];
                }
                else
                {
                    if (!fCreate)
                    {
                        return(null);
                    }
                    var next = new NamespaceNodeInfo(search);
                    node.Children.Add(search, next);
                    node = next;
                }
                tokens.RemoveAt(0);
            }
            return(node);
        }
        private NamespaceNodeInfo FindServiceNode(IEnumerable<string> urlTokens, bool fCreate = false)
        {
            if (urlTokens == null || !urlTokens.Any())
                return _rootNode;

            var tokens = new List<string>(urlTokens);

            var node = _rootNode;
            while (tokens.Count > 0)
            {
                var search = tokens[0].ToLowerInvariant();
                if (string.IsNullOrEmpty(search))
                {
                    tokens.RemoveAt(0);
                    continue;
                }

                if (node.Children.ContainsKey(search))
                {
                    node = node.Children[search];
                }
                else
                {
                    if (!fCreate)
                        return null;
                    var next = new NamespaceNodeInfo(search);
                    node.Children.Add(search, next);
                    node = next;
                }
                tokens.RemoveAt(0);
            }
            return node;
        }