예제 #1
0
        public override HttpControllerDescriptor SelectController(System.Net.Http.HttpRequestMessage request)
        {
            string tControllerName = this.GetControllerName(request);
            string tActionName     = request.GetRouteData().Values["action"] as string ?? string.Empty;

            CommandControllerDescriptor tDescriptor = this.mCommandControllerDescriptorProvider.GetControllerDescriptor(tControllerName, tActionName, request.Method.Method);

            return(tDescriptor != null ? tDescriptor.ControllerDescriptor : base.SelectController(request));
        }
예제 #2
0
        public override HttpActionDescriptor SelectAction(HttpControllerContext controllerContext)
        {
            CommandControllerDescriptor tDescriptor = this.mControllerDescriptorProvider.GetControllerDescriptor(
                controllerContext.ControllerDescriptor.ControllerName,
                controllerContext.RouteData.Values["action"] as string,
                controllerContext.Request.Method.Method
                );

            if (tDescriptor != null)
            {
                Type tControllerType = tDescriptor.ControllerDescriptor.ControllerType;

                return(new ReflectedHttpActionDescriptor(controllerContext.ControllerDescriptor,
                                                         tControllerType.GetMethod("Execute", BindingFlags.Public | BindingFlags.Instance)
                                                         ));
            }

            return(base.SelectAction(controllerContext));
        }