コード例 #1
0
    public IReadOnlyList <RouteEntry> GetDirectRoutes(HttpControllerDescriptor controllerDescriptor, IReadOnlyList <HttpActionDescriptor> actionDescriptors, IInlineConstraintResolver constraintResolver)
    {
        var realDirectRouteProvider = new DefaultDirectRouteProvider();
        var directRoutes            = realDirectRouteProvider.GetDirectRoutes(controllerDescriptor, actionDescriptors, constraintResolver);

        // Store the routes in a property so that they can be retrieved later
        DirectRoutes = directRoutes;
        return(directRoutes);
    }
コード例 #2
0
        public IReadOnlyList <RouteEntry> GetDirectRoutes(ControllerDescriptor controllerDescriptor, IReadOnlyList <ActionDescriptor> actionDescriptors, IInlineConstraintResolver constraintResolver)
        {
            // Get routes from default provider
            var defaultProvider = new DefaultDirectRouteProvider();
            var routes          = defaultProvider.GetDirectRoutes(controllerDescriptor, actionDescriptors, constraintResolver);

            // Create new constraint to accept only supported url prefixes
            var lc = new LocaleConstraint();

            // Add locale parameter and constraint to every route
            foreach (var item in routes)
            {
                item.Route.Url = "{locale}/" + item.Route.Url;
                item.Route.Constraints.Add("locale", lc);
            }
            return(routes);
        }