public static TypedRoute TypedRoute(this HttpConfiguration config, string template, Action<TypedRoute> configSetup)
        {
            var route = new TypedRoute(template);
            configSetup(route);

            if (TypedDirectRouteProvider.Routes.ContainsKey(route.ControllerType))
            {
                var controllerLevelDictionary = TypedDirectRouteProvider.Routes[route.ControllerType];
                controllerLevelDictionary.Add(route.ActionName, route);
            }
            else
            {
                var controllerLevelDictionary = new Dictionary<string, TypedRoute> { { route.ActionName, route } };
                TypedDirectRouteProvider.Routes.Add(route.ControllerType, controllerLevelDictionary);
            }

            return route;
        }
コード例 #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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        private static TypedRoute AddRoute(string template, Action <TypedRoute> configSetup)
        {
            var route = new TypedRoute(template);

            configSetup(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);
        }