Esempio n. 1
0
        private MvcSiteMapMenuNode CreateAuthorizedMenu(MvcSiteMapNode menu)
        {
            MvcSiteMapMenuNode authorizedMenu = new MvcSiteMapMenuNode();

            authorizedMenu.Title     = ResourceProvider.GetSiteMapTitle(menu.Area, menu.Controller, menu.Action);
            authorizedMenu.IconClass = menu.IconClass;

            authorizedMenu.Controller = menu.Controller;
            authorizedMenu.Action     = menu.Action;
            authorizedMenu.Area       = menu.Area;

            authorizedMenu.Submenus         = GetAuthorizedMenus(menu.Children);
            authorizedMenu.IsActive         = String.Compare(menu.Area, CurrentArea, true) == 0 && String.Compare(menu.Controller, CurrentController, true) == 0;
            authorizedMenu.HasActiveSubMenu = authorizedMenu.Submenus.Any(submenu => submenu.IsActive || submenu.HasActiveSubMenu);

            return(authorizedMenu);
        }
Esempio n. 2
0
        private MvcSiteMapMenus GetAuthorizedMenus(IEnumerable <MvcSiteMapNode> menus)
        {
            MvcSiteMapMenus authorizedMenus = new MvcSiteMapMenus();

            foreach (MvcSiteMapNode menu in menus)
            {
                if (IsAuthorizedToView(menu))
                {
                    MvcSiteMapMenuNode authorizedMenu = CreateAuthorizedMenu(menu);

                    if (!IsEmpty(authorizedMenu))
                    {
                        authorizedMenus.Add(authorizedMenu);
                    }
                }
            }

            return(authorizedMenus);
        }
Esempio n. 3
0
 private Boolean IsEmpty(MvcSiteMapMenuNode menu)
 {
     return(menu.Action == null && !menu.Submenus.Any());
 }