예제 #1
0
        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;
        }
예제 #4
0
        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);
        }
예제 #8
0
        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);
 }
예제 #14
0
 public static void Action(this INavigatable navigatable, string actionName, string controllerName, object routeValues)
 {
     navigatable.ControllerName = controllerName;
     navigatable.ActionName     = actionName;
     navigatable.SetRouteValues(routeValues);
 }
예제 #15
0
 public static void Route(this INavigatable navigatable, string routeName, object routeValues)
 {
     navigatable.RouteName = routeName;
     navigatable.SetRouteValues(routeValues);
 }
예제 #16
0
 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();
 }