Esempio n. 1
0
        private void setCurrent()
        {
            if (String.IsNullOrWhiteSpace(currentPath))
            {
                return;
            }

            var currentValue = breadCrumbs.FirstOrDefault(x => x.Key.Equals(currentPath) && x.Current.Equals(true));

            if (currentValue == null)
            {
                //There can only be one!!
                var currentCurrnet = breadCrumbs.FirstOrDefault(x => x.Current.Equals(true));
                if (currentCurrnet != null)
                {
                    currentCurrnet.Current = false;
                }


                var data = new BreadCrumbDataClass();
                data.Key        = currentPath;
                data.Display    = currentPath;
                data.Parameters = setParameters(currentQuery);
                data.Current    = true;

                breadCrumbs.Add(data);
            }
        }
        private static string setLinkItemParemeters(BreadCrumbDataClass crumb)
        {
            if (crumb.Parameters == null || crumb.Parameters.Count.Equals(0))
            {
                return(String.Empty);
            }

            var parameter = new List <string>();

            foreach (var p in crumb.Parameters)
            {
                parameter.Add(String.Format("{0}={1}", p.Key, p.Value));
            }

            return("?" + String.Join("&", parameter.ToArray()));
        }
        private static string setLinkItem(BreadCrumbDataClass crumb)
        {
            var item = new StringBuilder();

            if (!crumb.Current)
            {
                item.AppendLine("<li class=\"breadcrumb-item \">");
                item.AppendLine(String.Format("<a href=\"{0}{1}\" >{2}</a>", crumb.Key, setLinkItemParemeters(crumb), crumb.Display));
            }
            else
            {
                item.AppendLine("<li class=\"breadcrumb-item active\" aria-current=\"page\">");
                item.AppendLine(crumb.Display);
            }



            item.AppendLine("</li>");
            return(item.ToString());
        }
Esempio n. 4
0
        private void setBreadCrumbs()
        {
            if (referers.Count > 0)
            {
                var urlValue     = referers[0].ToString();
                var urlElements  = urlValue.Split("/").ToList();
                var hostLocation = urlElements.IndexOf(this.Request.Host.Value);
                if (urlElements.Count() > hostLocation)
                {
                    var razorPageURL = urlElements[hostLocation + 1];
                    var razorPage    = razorPageURL.Split("?");
                    if (razorPage.Count() > 0)
                    {
                        var data = new BreadCrumbDataClass();
                        data.Key     = razorPage[0].ToString();
                        data.Display = data.Key;
                        if (String.IsNullOrWhiteSpace(data.Key))
                        {//This means you have come from the home page.
                            data.Key     = "Index";
                            data.Display = "Home";
                        }
                        //Make sure I'm not adding the page back in I have removed
                        if (crumbRemoved.FirstOrDefault(x => x.Equals(data.Key)) != null)
                        {
                            return;
                        }

                        if (setCurrentAsDisabled(data.Key))
                        {
                            return;//Do not set if already exists
                        }
                        if (razorPage.Count().Equals(2))
                        {
                            data.Parameters = setParameters(razorPage[1]);
                        }
                        breadCrumbs.Add(data);
                    }
                }
            }
        }