Example #1
0
        internal void AddRoute(RHttpAction action, HttpMethod method)
        {
            RouteTree rt;

            if (!_trees.TryGetValue(method, out rt))
            {
                rt = new RouteTree("", null);
                _trees.Add(method, rt);
            }
            AddToTree(rt, action);
        }
Example #2
0
        private static void AddToTree(RouteTree tree, RHttpAction action)
        {
            var rTree = action.RouteTree;
            var len   = rTree.Length;

            for (var i = 0; i < len; i++)
            {
                var ntree = tree.
                            AddBranch(rTree[i]);
                tree = ntree;
            }
            if (tree.Action != null)
            {
                throw new RHttpServerException("Cannot add two actions to the same route");
            }
            tree.Action = action;
        }
Example #3
0
        internal RouteTree AddBranch(string route)
        {
            switch (route)
            {
            case "*":
                return(General ?? (General = new RouteTree(route, this)));

            case "^":
                return(Parameter ?? (Parameter = new RouteTree(route, this)));

            default:
                RouteTree nr;
                if (Specific.TryGetValue(route, out nr))
                {
                    return(nr);
                }
                nr = new RouteTree(route, this);
                Specific.Add(route, nr);
                return(nr);
            }
        }
Example #4
0
 internal RouteTree(string route, RouteTree stem)
 {
     Stem  = stem;
     Route = route;
 }