Exemple #1
0
        private static string Action <TController>(
            this IUrlHelper helper,
            Expression <Func <TController, Task> > action,
            UrlActionContext actionContext)
            where TController : class
        {
            ExpressionRouteValues expressionRouteValues = GetExpresionRouteHelper(helper).Resolve(action, actionContext.Values);

            ApplyRouteValues(actionContext, expressionRouteValues);
            return(helper.Action(actionContext));
        }
Exemple #2
0
        /// <summary>
        /// Generates an absolute URL using the specified route name, <see cref="Expression{TDelegate}"/> for an action method,
        /// from which action name, controller name and route values are resolved, and the specified additional route values.
        /// </summary>
        /// <typeparam name="TController">Controller, from which the action is specified.</typeparam>
        /// <param name="routeName">The name of the route that is used to generate the URL.</param>
        /// <param name="action">
        /// The <see cref="Expression{TDelegate}"/>, from which action name,
        /// controller name and route values are resolved.
        /// </param>
        /// <param name="values">An object that contains additional route values.</param>
        /// <returns>The generated absolute URL.</returns>
        public static string Link <TController>(
            this IUrlHelper helper,
            string routeName,
            Expression <Func <TController, Task> > action,
            object values)
            where TController : class
        {
            ExpressionRouteValues expressionRouteValues = GetExpresionRouteHelper(helper).Resolve(action, values, addControllerAndActionToRouteValues: true);

            return(helper.Link(routeName, expressionRouteValues.RouteValues));
        }
Exemple #3
0
 private static void ApplyRouteValues(UrlActionContext actionContext, ExpressionRouteValues expressionRouteValues)
 {
     actionContext.Controller = expressionRouteValues.Controller;
     actionContext.Action     = expressionRouteValues.Action;
     actionContext.Values     = expressionRouteValues.RouteValues;
 }