Example #1
0
        public static Menu BuildMenu(ControllerContext controllerContext, string menuName, string areaName, bool initialize)
        {
            Menu menu = new Menu();

            MenuTemplate menuTemplate = new MenuTemplate();
            if (!string.IsNullOrEmpty(menuName) && menuTemplates.ContainsKey(menuName))
            {
                menuTemplate = menuTemplates[menuName];
            }
            else
            {
                menuTemplate = defaultMenu;
            }
            menu.Name = menuName;

            menu.Items = GetItems(areaName, menuTemplate.ItemContainers, controllerContext);

            InjectMenu(menu, controllerContext);

            if (initialize)
            {
                menu.Initialize(controllerContext);
            }

            return menu;
        }
Example #2
0
 static MenuFactory()
 {
     defaultMenu = new MenuTemplate();
     Configuration.MenuSection menuSection = Configuration.MenuSection.GetSection();
     if (menuSection != null)
     {
         defaultMenu.ItemContainers = CreateItems(menuSection.Items, new List<IMenuItemContainer>());
     }
 }
Example #3
0
 public static void RegisterAreaMenu(string menuName, string menuFileName)
 {
     lock (menuTemplates)
     {
         Configuration.MenuSection menuSection = Configuration.MenuSection.GetSection(menuFileName);
         if (menuSection != null)
         {
             MenuTemplate areaMenu = new MenuTemplate();
             areaMenu.ItemContainers = CreateItems(menuSection.Items, new List<IMenuItemContainer>());
             menuTemplates.Add(menuName, areaMenu);
         }
     }
 }