private string SelectController(NavigationSourceRoutingConvention convention, ODataPath odataPath, HttpRequest request) { RouteContext routeContext = new RouteContext(request.HttpContext); routeContext.HttpContext.ODataFeature().Path = odataPath; ControllerActionDescriptor descriptor = convention.SelectAction(routeContext)?.FirstOrDefault(); return(descriptor?.ControllerName); }
internal static string SelectAction(NavigationSourceRoutingConvention convention, ODataPath odataPath, HttpRequestMessage request, ILookup <string, HttpActionDescriptor> actionMap, string controllerName = "ControllerName") { // Construct parameters. HttpRequestContext requestContext = new HttpRequestContext(); HttpControllerContext controllerContext = new HttpControllerContext { Request = request, RequestContext = requestContext, RouteData = new HttpRouteData(new HttpRoute()) }; controllerContext.Request.SetRequestContext(requestContext); // Select the action. string result = convention.SelectAction(odataPath, controllerContext, actionMap); return(result); }
internal static string SelectAction(NavigationSourceRoutingConvention convention, ODataPath odataPath, HttpRequest request, IEnumerable <ControllerActionDescriptor> actionMap, string controllerName = "ControllerName") { // COnstruct parameters. RouteContext routeContext = new RouteContext(request.HttpContext); routeContext.HttpContext.ODataFeature().Path = odataPath; SelectControllerResult controllerResult = new SelectControllerResult(controllerName, null); // Select the action. string result = convention.SelectAction(routeContext, controllerResult, actionMap); // Copy route data to the context. In the real pipeline, this occurs in // RouterMiddleware.cs after the request has been routed. request.HttpContext.Features[typeof(IRoutingFeature)] = new RoutingFeature() { RouteData = routeContext.RouteData, }; return(result); }
private string SelectController(NavigationSourceRoutingConvention convention, ODataPath odataPath, HttpRequestMessage request) { return(convention.SelectController(odataPath, request)); }