示例#1
0
        public void Push(ActionExecutingContext context, string label)
        {
            var key =
                context.HttpContext.Request.Url.LocalPath
                .ToLower()
                .GetHashCode();

            if (Crumbs.Any(x => x.Key == key))
            {
                var newCrumbs = new List<StateEntry>();
                var remove = false;
                // We've seen this route before, maybe user clicked on a breadcrumb
                foreach (var crumb in Crumbs)
                {
                    if (crumb.Key == key)
                    {
                        remove = true;
                    }
                    if (!remove)
                    {
                        newCrumbs.Add(crumb);
                    }
                }
                Crumbs = newCrumbs;
            }

            Current = new StateEntry().WithKey(key)
                .SetContext(context)
                .WithUrl(context.HttpContext.Request.Url.ToString())
                .WithLabel(label);

            Crumbs.Add(Current);
        }
示例#2
0
        public static void Add(string url, string label)
        {
            // get a key for the Url.
            var key =
               url
               .ToLower()
               .GetHashCode();

            var current = new StateEntry().WithKey(key)
             .WithUrl(url)
             .WithLabel(label);

            StateManager.GetState(SessionProvider.SessionId).Crumbs.Add(current);
        }
示例#3
0
        private void Add(string url, string label, Type resourceType = null, ActionExecutingContext actionContext = null)
        {
            var key = url.ToLowerInvariant().GetHashCode();

            // when pushing entries into the list determine their level in hierarchy so that
            // deeper links are added to the end of the list
            int levels = BreadCrumb.HierarchyProvider.GetLevel(url);

            if (Crumbs.Any(x => x.Key == key))
            {
                var newCrumbs = new SortedSet <StateEntry>(new StateEntryComparer());
                var remove    = false;
                // We've seen this route before, maybe user clicked on a breadcrumb
                foreach (var crumb in Crumbs)
                {
                    if (crumb.Key == key)
                    {
                        remove = true;
                    }
                    if (!remove)
                    {
                        newCrumbs.Add(crumb);
                    }
                }
                Crumbs = newCrumbs;
            }

            Current = new StateEntry()
                      .WithKey(key)
                      .SetContext(actionContext)
                      .WithUrl(url)
                      .WithLevel(levels)
                      .WithLabel(ResourceHelper.GetResourceLookup(resourceType, label));

            Crumbs.Add(Current);
        }
示例#4
0
 public bool Equals(StateEntry obj)
 {
     if (GetHashCode() != obj.GetHashCode()) return false;
     return Url.Equals(obj.Url, StringComparison.InvariantCultureIgnoreCase);
 }