public string Url(INavigatable navigatable, Action<RouteValueDictionary> configurator)
        {
            RouteValueDictionary routeValues = PrepareRouteValues(navigatable.RouteValues);
            configurator(routeValues);

            return navigatable.GenerateUrl(grid.ViewContext, grid.UrlGenerator, routeValues);
        }
示例#2
0
        public Uri Generate(RequestContext requestContext, INavigatable navigatable, RouteValueDictionary routeValues)
        {
            if (requestContext == null)
            {
                throw new ArgumentNullException(nameof(requestContext));
            }

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

            var urlHelper = new UrlHelper(requestContext);

            if (!String.IsNullOrEmpty(navigatable.RouteName))
            {
                return new Uri(uriString: urlHelper.RouteUrl(navigatable.RouteName, routeValues));
            }
            
            if (!String.IsNullOrEmpty(navigatable.ControllerName) && !String.IsNullOrEmpty(navigatable.ActionName))
            {
                return new Uri(uriString: urlHelper.Action(navigatable.ActionName, navigatable.ControllerName, routeValues), uriKind: UriKind.Relative);
            }

            if (routeValues.Any())
            {
                return new Uri(uriString: urlHelper.RouteUrl(routeValues));
            }

            return null;
        }
示例#3
0
        public string Generate(RequestContext requestContext, INavigatable navigationItem, RouteValueDictionary routeValues)
        {
            Guard.IsNotNull(requestContext, "requestContext");
            Guard.IsNotNull(navigationItem, "navigationItem");

            UrlHelper 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 string Url(INavigatable navigatable, string key, object value)
        {
            RouteValueDictionary routeValues = PrepareRouteValues(navigatable.RouteValues);

            routeValues[grid.Prefix(key)] = value;

            return Url(routeValues);
        }
        public static void Apply(this RouteValueDictionary source, INavigatable navigatable, Action<INavigatable, string, string, RouteValueDictionary> callback)
        {
            object controllerName;
            object actionName;
            var routeValues = new RouteValueDictionary();

            ExtractControllerAndActionParams(routeValues, out controllerName, out actionName, source);

            callback(navigatable, (string) actionName, (string) controllerName, routeValues);
        }
示例#6
0
        public Uri Generate(RequestContext requestContext, INavigatable navigatable)
        {
            var routeValues = new RouteValueDictionary();

            if (navigatable.RouteValues.Any())
            {
                routeValues.Merge(navigatable.RouteValues);
            }

            return Generate(requestContext, navigatable, routeValues);
        }
示例#7
0
        public string Generate(RequestContext requestContext, INavigatable navigationItem)
        {
            RouteValueDictionary routeValues = new RouteValueDictionary();

            if (navigationItem.RouteValues.Any())
            {
                routeValues.Merge(navigationItem.RouteValues);
            }

            return Generate(requestContext, navigationItem, routeValues);
        }
        public bool IsAccessibleToUser(RequestContext requestContext, INavigatable navigationItem)
        {
            bool isAllowed = true;

            if (!string.IsNullOrEmpty(navigationItem.RouteName))
            {
                isAllowed = controllerAuthorization.IsAccessibleToUser(requestContext, navigationItem.RouteName);
            }
            else if (!string.IsNullOrEmpty(navigationItem.ControllerName) && !string.IsNullOrEmpty(navigationItem.ActionName))
            {
                isAllowed = controllerAuthorization.IsAccessibleToUser(requestContext, navigationItem.ControllerName, navigationItem.ActionName, navigationItem.RouteValues);
            }

            return isAllowed;
        }
 private static void SetAction(INavigatable navigatable, string actionName, string controllerName, RouteValueDictionary routeValues)
 {
     navigatable.ActionName = actionName;
     navigatable.ControllerName = controllerName;
     navigatable.SetRouteValues((IDictionary<string, object>)routeValues);
 }
 private void SetUrl(INavigatable operation)
 {
     operation.Url = operation.GenerateUrl(viewContext, urlGenerator);
 }
示例#11
0
 private static void ApplyRoute(INavigatable navigatable,string controllerName,string actionName,RouteValueDictionary routeValues)
 {
     navigatable.ControllerName = controllerName;
     navigatable.ActionName = actionName;
     navigatable.SetRouteValues(routeValues);
 }
示例#12
0
        public string Url(INavigatable navigatable, bool copy)
        {
            var routeValues = new RouteValueDictionary(navigatable.RouteValues);

            if (copy)
            {
                routeValues = PrepareRouteValues(navigatable.RouteValues);
            }

            return navigatable.GenerateUrl(grid.ViewContext, grid.UrlGenerator, routeValues);
        }
示例#13
0
 public string Url(INavigatable navigatable)
 {
     return Url(navigatable, true);
 }
 public static void Action(this INavigatable navigatable, string actionName, string controllerName, object routeValues)
 {
     navigatable.ControllerName = controllerName;
     navigatable.ActionName     = actionName;
     navigatable.SetRouteValues(routeValues);
 }
 public static void Route(this INavigatable navigatable, string routeName, object routeValues)
 {
     navigatable.RouteName = routeName;
     navigatable.SetRouteValues(routeValues);
 }
 public static void Route(this INavigatable navigatable, string routeName, RouteValueDictionary routeValues)
 {
     navigatable.RouteName = routeName;
     navigatable.SetRouteValues(routeValues);
 }
示例#17
0
 private Uri GenerateUrl(INavigatable navigatable)
 {
     var routeValues = PrepareRouteData(navigatable.RouteValues);
     return navigatable.GenerateUrl(grid.ViewContext, grid.UrlGenerator, routeValues);
 }
示例#18
0
        private string GetUrl(INavigatable node, HttpContextBase httpContext, string applicationRoot)
        {
            string url = urlGenerator.Generate(httpContext.RequestContext(), node);

            if (!string.IsNullOrEmpty(url))
            {
                if (!url.StartsWith("/", StringComparison.Ordinal))
                {
                    url = "/" + url;
                }

                url = applicationRoot + url;
            }

            return url;
        }
示例#19
0
 public string PrepareUrl(INavigatable navigatable)
 {
     return navigatable.GenerateUrl(viewContext, urlGenerator);
 }
示例#20
0
        public string Url(INavigatable navigatable, string key, object value)
        {
            RouteValueDictionary routeValues = PrepareRouteValues(navigatable.RouteValues);

            routeValues[grid.Prefix(key)] = value;

            return navigatable.GenerateUrl(grid.ViewContext, grid.UrlGenerator, routeValues);
        }
示例#21
0
 public AutoMoveNavMesh(INavigatable pNavigatable) : base(pNavigatable)
 {
     Init();
 }