/// <summary>
 /// Retrieve all ancestors
 /// </summary>
 /// <param name="node">the node</param>
 /// <returns></returns>
 private void GetAncestors(SiteMapNodeModel node)
 {
     if (node.Parent != null)
     {
         ancestors.Add(node.Parent);
         GetAncestors(node.Parent);
     }
 }
示例#2
0
 /// <summary>
 /// Retrieve all descendants
 /// </summary>
 /// <param name="node">the node</param>
 /// <returns></returns>
 private void GetDescendants(SiteMapNodeModel node)
 {
     foreach (var child in node.Children)
     {
         descendants.Add(child);
         GetDescendants(child);
     }
 }
        /// <summary>
        /// Retrieve all descendants
        /// </summary>
        /// <param name="node">the node</param>
        /// <returns></returns>
        private void GetDescendants(SiteMapNodeModel node)
        {
            var sortedNodes = SortSiteMapNodes <SiteMapNodeModel>(node.Children);

            foreach (var child in sortedNodes)
            {
                descendants.Add(child);
                GetDescendants(child);
            }
        }
示例#4
0
 private void FindNearestVisibleDescendants(ISiteMapNode node, int maxDepth)
 {
     foreach (var child in node.ChildNodes)
     {
         if (child.IsAccessibleToUser())
         {
             if (child.IsVisible(SourceMetadata))
             {
                 nearestVisibleDescendantsList.Add(new SiteMapNodeModel(child, SourceMetadata, maxDepth - 1, drillDownToCurrent, false, VisibilityAffectsDescendants));
             }
             else if (maxDepth > 0)
             {
                 FindNearestVisibleDescendants(child, maxDepth - 1);
             }
         }
     }
 }
示例#5
0
        /// <summary>
        /// Retrieve all descendants
        /// </summary>
        /// <param name="node">the node</param>
        /// <returns></returns>
        private void GetDescendants(SiteMapNodeModel node)
        {
            IEnumerable <SiteMapNodeModel> sortedNodes;

            if (node.Children.Any(x => x.Order != 0))
            {
                sortedNodes = node.Children.OrderBy(x => x.Order);
            }
            else
            {
                sortedNodes = node.Children;
            }
            foreach (var child in sortedNodes)
            {
                descendants.Add(child);
                GetDescendants(child);
            }
        }
        public static SiteMapNodeModel GetTopMenu(List <RoleInfo> menulist)
        {
            List <RoleInfo>      topmenulist        = new List <RoleInfo>();
            SiteMapNodeModelList topMenuModelList   = new SiteMapNodeModelList();
            SiteMapNodeModelList childMenuModelList = new SiteMapNodeModelList();

            if (menulist != null)
            {
                topmenulist = menulist.FindAll(p => p.ParentId == 0);
            }
            if (topmenulist != null)
            {
                foreach (RoleInfo tmenu in topmenulist)
                {
                    childMenuModelList = new SiteMapNodeModelList();
                    foreach (RoleInfo pmenu in menulist.FindAll(p => p.ParentId == tmenu.Id))
                    {
                        childMenuModelList.Add(new SiteMapNodeModel
                        {
                            Action     = pmenu.Action,
                            Controller = pmenu.Controller,
                            Title      = pmenu.Name,
                            AppYN      = pmenu.AppYN,
                            //Description = pmenu.Description
                        });
                    }
                    topMenuModelList.Add(new SiteMapNodeModel
                    {
                        Action     = tmenu.Action,
                        Controller = tmenu.Controller,
                        Title      = tmenu.Name,
                        AppYN      = tmenu.AppYN,
                        //Description = tmenu.Description,
                        Children = childMenuModelList
                    });
                }
            }
            SiteMapNodeModelList result = new SiteMapNodeModelList();

            result.Add(new SiteMapNodeModel {
                Children = topMenuModelList
            });
            return(result.FirstOrDefault());
        }