public static string Generate(RequestContext requestContext, NavigationRequest navigationItem, RouteValueDictionary routeValues) { if (requestContext == null) throw new ArgumentNullException("requestContext"); if (navigationItem == null) throw new ArgumentNullException("navigationItem"); var urlHelper = new UrlHelper(requestContext); string generatedUrl = null; if (!string.IsNullOrEmpty(navigationItem.RouteName)) { generatedUrl = urlHelper.RouteUrl(navigationItem.RouteName, routeValues); } else if (!string.IsNullOrEmpty(navigationItem.ControllerName) && !string.IsNullOrEmpty(navigationItem.ActionName)) { generatedUrl = urlHelper.Action(navigationItem.ActionName, navigationItem.ControllerName, routeValues, null, null); } else if (!string.IsNullOrEmpty(navigationItem.Url)) { generatedUrl = navigationItem.Url.StartsWith("~/", StringComparison.Ordinal) ? urlHelper.Content(navigationItem.Url) : navigationItem.Url; } else if (routeValues.Any()) { generatedUrl = urlHelper.RouteUrl(routeValues); } return generatedUrl; }
public static string Generate(RequestContext requestContext, NavigationRequest navigationItem) { var routeValues = new RouteValueDictionary(); if (navigationItem.RouteValues.Any()) routeValues.Merge(navigationItem.RouteValues); return Generate(requestContext, navigationItem, routeValues); }
public Link(ViewContext viewContext) : base(viewContext) { Encode = true; Navigation = new NavigationRequest(); }
public Link(RequestContext requestContext) : base(requestContext) { Encode = true; Navigation = new NavigationRequest(); }
public Link(HtmlHelper htmlHelper) : base(htmlHelper) { Encode = true; Navigation = new NavigationRequest(); }