Exemple #1
0
        public bool TryGet(string[] block, int depth, out RouterNode <T> result)
        {
            var word = block[depth];

            if (this.childrun.TryGetValue(word.ToLower(), out result) == false)
            {
                if (this.childrun.TryGetValue(_parameterWord, out result) == false)
                {
                    return(false);
                }
            }

            depth++;

            if (depth < block.Length)
            {
                return(result.TryGet(block, depth, out result));
            }
            else
            {
                return(true);
            }
        }
Exemple #2
0
        public void Add(string[] block, int depth, T value)
        {
            var currentWord  = block[depth];
            var replacedWord = RouteHelper.IsParameter(currentWord) ? _parameterWord : currentWord.ToLower();

            if (childrun.TryGetValue(replacedWord, out var child) == false)
            {
                string fullPath = string.Join('/', block, 0, depth + 1);
                child = new RouterNode <T>(depth, replacedWord, fullPath);

                this.childrun.Add(child.word, child);
            }

            depth++;

            if (depth < block.Length)
            {
                child.Add(block, depth, value);
            }
            else
            {
                child.Value = value;
            }
        }
Exemple #3
0
 public Router()
 {
     _rootNode = new RouterNode <HttpAction>();
 }