private ITypedRouteBuilder AddRoute(string template, Action <ITypedRoute> configuration, params string[] httpMethods)
        {
            // Action template should be replaced because we are actually using attribute route models.
            var route = new TypedRoute(template.Trim('/').Replace("{action}", "[action]"), httpMethods);

            configuration(route);

            if (routes.ContainsKey(route.ControllerType))
            {
                var controllerActions = routes[route.ControllerType];
                controllerActions.Add(route);
            }
            else
            {
                var controllerActions = new List <TypedRoute> {
                    route
                };
                routes.Add(route.ControllerType, controllerActions);
            }

            return(this);
        }
示例#2
0
        private TypedRoute AddRoute(string template, Action <TypedRoute> configuration)
        {
            // Action template should be replaced because we are actually using attribute route models.
            var route = new TypedRoute(template.Replace("{action}", "[action]"));

            configuration(route);

            if (TypedRoutingApplicationModelConvention.Routes.ContainsKey(route.ControllerType))
            {
                var controllerActions = TypedRoutingApplicationModelConvention.Routes[route.ControllerType];
                controllerActions.Add(route);
            }
            else
            {
                var controllerActions = new List <TypedRoute> {
                    route
                };
                TypedRoutingApplicationModelConvention.Routes.Add(route.ControllerType, controllerActions);
            }

            return(route);
        }