示例#1
0
        private bool IsAllowedByAdjuster(TreeNode <NavigationNode> node)
        {
            string key = NavigationNodeAdjuster.KeyPrefix + node.Value.Key;

            if (context.Items[key] != null)
            {
                NavigationNodeAdjuster adjuster = (NavigationNodeAdjuster)context.Items[key];
                if (adjuster.ViewFilterName == navigationFilterName)
                {
                    if (adjuster.AdjustRemove)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
示例#2
0
        public string AdjustText(TreeNode <NavigationNode> node)
        {
            string key = NavigationNodeAdjuster.KeyPrefix + node.Value.Key;

            if (context.Items[key] != null)
            {
                NavigationNodeAdjuster adjuster = (NavigationNodeAdjuster)context.Items[key];
                if (adjuster.ViewFilterName == navigationFilterName)
                {
                    if (adjuster.AdjustedText.Length > 0)
                    {
                        return(adjuster.AdjustedText);
                    }
                }
            }

            return(node.Value.Text);
        }
示例#3
0
        public string AdjustUrl(TreeNode <NavigationNode> node)
        {
            string urlToUse = string.Empty;

            try
            {
                if ((node.Value.Action.Length > 0) && (node.Value.Controller.Length > 0))
                {
                    if (node.Value.PreservedRouteParameters.Length > 0)
                    {
                        List <string> preservedParams = node.Value.PreservedRouteParameters.SplitOnChar(',');
                        //var queryBuilder = new QueryBuilder();
                        //var routeParams = new { };
                        var queryStrings = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
                        foreach (string p in preservedParams)
                        {
                            if (context.Request.Query.ContainsKey(p))
                            {
                                queryStrings.Add(p, context.Request.Query[p]);
                            }
                        }

                        urlToUse = urlHelper.Action(node.Value.Action, node.Value.Controller, new { area = node.Value.Area });

                        if ((urlToUse != null) && (queryStrings.Count > 0))
                        {
                            urlToUse = QueryHelpers.AddQueryString(urlToUse, queryStrings);
                        }
                    }
                    else
                    {
                        urlToUse = urlHelper.Action(node.Value.Action, node.Value.Controller, new { area = node.Value.Area });
                    }
                }
                else if (node.Value.NamedRoute.Length > 0)
                {
                    urlToUse = urlHelper.RouteUrl(node.Value.NamedRoute);
                }

                string key = NavigationNodeAdjuster.KeyPrefix + node.Value.Key;

                if (context.Items[key] != null)
                {
                    NavigationNodeAdjuster adjuster = (NavigationNodeAdjuster)context.Items[key];
                    if (adjuster.ViewFilterName == navigationFilterName)
                    {
                        if (adjuster.AdjustedUrl.Length > 0)
                        {
                            return(adjuster.AdjustedUrl);
                        }
                    }
                }

                if (string.IsNullOrEmpty(urlToUse))
                {
                    return(node.Value.Url);
                }
            }
            catch (ArgumentOutOfRangeException ex)
            {
                log.LogError("error handled for " + node.Value.Key, ex);
            }


            //if(urlToUse.Length > 0) { return urlToUse; }

            return(urlToUse);
        }