Esempio n. 1
0
        private SitemapNodeDefination FindSitemapNode(string nodeName, SitemapNodeDefination node)
        {
            if (string.IsNullOrEmpty(nodeName) || string.Equals(nodeName, node.Name, StringComparison.OrdinalIgnoreCase))
            {
                return node;
            }

            foreach (var child in node.Nodes)
            {
                var foundInChild = FindSitemapNode(nodeName, child);
                if (foundInChild != null)
                {
                    return foundInChild;
                }
            }
            return null;
        }
        private static SitemapNodeDefination MakeNode(SitemapNodeAttribute sitemapNodeAttr, IUrl url )
        {
            var sitemapNode = new SitemapNodeDefination
            {
                IsHidden = sitemapNodeAttr.IsHidden,
                Text = () => sitemapNodeAttr.GetText(),
                Group = () => sitemapNodeAttr.GetGroup(),
                Icon = sitemapNodeAttr.Icon,
                Order = sitemapNodeAttr.Order,
                SiteMap = sitemapNodeAttr.SiteMap ?? GlobalSitemaps.DefaultSiteMap.Name,
            };

            if (string.IsNullOrEmpty(sitemapNodeAttr.Name))
            {
                sitemapNodeAttr.Name = Guid.NewGuid().ToString("N");
            }
            sitemapNode.Name = sitemapNodeAttr.Name;
            sitemapNode.Url = url;
            return sitemapNode;
        }
Esempio n. 3
0
 public void Add(SitemapNodeDefination siteMap)
 {
     _siteMaps.Add(siteMap);
 }
 private SitemapNode Create(SitemapNodeDefination sitemapNodeDefination, SitemapNode parent, RequestContext requestContext)
 {
     SitemapNode node = new SitemapNode
     {
         Icon = sitemapNodeDefination.Icon,
         Name = sitemapNodeDefination.Name,
         Parent = parent,
         Url = sitemapNodeDefination.Url.MakeUrl(requestContext),
         IsCurrent = sitemapNodeDefination.Url.IsCurrent(requestContext),
         Text = sitemapNodeDefination.Text(),
         Group = sitemapNodeDefination.Group(),
         Order = sitemapNodeDefination.Order,
         IsHidden = sitemapNodeDefination.IsHidden,
     };
     foreach (var childNodeDefination in sitemapNodeDefination.Nodes)
     {
         var childNode = Create(childNodeDefination, node, requestContext);
         if (childNode.IsCurrent)
         {
             childNode.InCurrent = true;
         }
         node.Nodes.Add(childNode);
     }
     node.Nodes = node.Nodes.OrderBy(x => x.Order).ToList();
     return node;
 }