/// <summary>
		/// This method copies logic from System.Web.Mvc.ControllerActionInvoker.FindAction
		/// </summary>
		public static RouteData FilterRouteData(RouteData routeData, HttpContextBase httpContext)
		{
			var mvcAssemblyReflector = new MvcAssemblyReflector();

			if (mvcAssemblyReflector.HasDirectRouteMatchFor(routeData))
			{
				var controllerContext = GetControllerContext(httpContext, routeData);

				var candidates = mvcAssemblyReflector.GetDirectRouteCandidatesFor(controllerContext);

				var bestCandidate = mvcAssemblyReflector.SelectBestCandidate(candidates, controllerContext);
				if (bestCandidate == null)
				{
					return null;
				}

				return mvcAssemblyReflector.GetRouteDataFrom(bestCandidate);
			}

			return routeData;
		}
示例#2
0
        /// <summary>
        /// This method copies logic from System.Web.Mvc.ControllerActionInvoker.FindAction
        /// </summary>
        public static RouteData FilterRouteData(RouteData routeData, HttpContextBase httpContext)
        {
            var mvcAssemblyReflector = new MvcAssemblyReflector();

            if (mvcAssemblyReflector.HasDirectRouteMatchFor(routeData))
            {
                var controllerContext = GetControllerContext(httpContext, routeData);

                var candidates = mvcAssemblyReflector.GetDirectRouteCandidatesFor(controllerContext);

                var bestCandidate = mvcAssemblyReflector.SelectBestCandidate(candidates, controllerContext);
                if (bestCandidate == null)
                {
                    return(null);
                }

                return(mvcAssemblyReflector.GetRouteDataFrom(bestCandidate));
            }

            return(routeData);
        }
 public static void MapAttributeRoutesInControllers(this RouteCollection routes, IEnumerable<Type> controllers, IInlineConstraintResolver constraintResolver, IDirectRouteProvider routeProvider)
 {
     var mvcAssemblyReflector = new MvcAssemblyReflector();
     mvcAssemblyReflector.MapAttributeRoutes(routes, controllers, constraintResolver, routeProvider);
 }
 public static void MapAttributeRoutesInControllers(this RouteCollection routes, IEnumerable<Type> controllers)
 {
     var mvcAssemblyReflector = new MvcAssemblyReflector();
     mvcAssemblyReflector.MapAttributeRoutes(routes, controllers);
 }