Exemplo n.º 1
0
        public string GetUri(IActionDescriptor action, IUrlHelper urlHelper, object obj)
        {
            if (obj == null)
            {
                return(GetUri(action, urlHelper));
            }

            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            if (urlHelper == null)
            {
                throw new ArgumentNullException(nameof(urlHelper));
            }

            var parameters = parser.Parse(action.Parameter);
            var values     = mapper.GetValues(parameters, obj);

            if (action.Controller == null)
            {
                return(urlHelper.Action(action.Action, values));
            }

            return(urlHelper.Action(action.Action, action.Controller, values));
        }
Exemplo n.º 2
0
        public string GetUri(IRouteDescriptor route, IUrlHelper urlHelper, object obj)
        {
            if (route == null)
            {
                throw new ArgumentNullException(nameof(route));
            }

            if (urlHelper == null)
            {
                throw new ArgumentNullException(nameof(urlHelper));
            }

            if (obj == null)
            {
                return(urlHelper.RouteUrl(route.RouteName));
            }

            var parameters = parser.Parse(route.Parameter);
            var values     = mapper.GetValues(parameters, obj);

            return(urlHelper.RouteUrl(route.RouteName, values));
        }