public NavigationItemBuilder(MenuItem existingItem)
        {
            if (existingItem == null)
            {
                throw new ArgumentNullException(nameof(existingItem));
            }

            _item = existingItem;
        }
Example #2
0
        /// <summary>
        /// Builds a menu item shape.
        /// </summary>
        /// <param name="shapeFactory">The shape factory.</param>
        /// <param name="parentShape">The parent shape.</param>
        /// <param name="menu">The menu shape.</param>
        /// <param name="menuItem">The menu item to build the shape for.</param>
        /// <returns>The menu item shape.</returns>
        public static dynamic BuildMenuItemShape(dynamic shapeFactory, dynamic parentShape, dynamic menu, MenuItem menuItem)
        {
            var menuItemShape = shapeFactory.MenuItem()
                .Text(menuItem.Text)
                .Id(menuItem.Id)
                .Href(menuItem.Href)
                .LinkToFirstChild(menuItem.LinkToFirstChild)
                .Selected(parentShape.Selected != null && ((bool)parentShape.Selected || IsSelected(menuItem, null)))
                .RouteValues(menuItem.RouteValues)
                .Item(menuItem)
                .Menu(menu)
                .Parent(parentShape)
                .Level(parentShape.Selected == null ? 1 : (int)parentShape.Level + 1)
                .Local(menuItem.Local);

            foreach (var className in menuItem.Classes)
                menuItemShape.Classes.Add(className);

            return menuItemShape;
        }
 public NavigationItemBuilder()
 {
     _item = new MenuItem();
 }
Example #4
0
 public NavigationBuilder Remove(MenuItem item)
 {
     Contained.Remove(item);
     return this;
 }
Example #5
0
 public static bool IsSelected(MenuItem menuItem, HttpContext httpContext)
 {
     return false;
 }