public void AddMenuItem(MenuItemBase parent, params MenuItemBase[] displayMenuItem) { foreach (var menuItemDefinition in displayMenuItem) { if (MenuItemNameList.Contains(menuItemDefinition.Name)) { throw new Exception("Menu item name duplicated"); } parent.Children.Add(menuItemDefinition); MenuItemNameList.Add(menuItemDefinition.Name); } }
public void AddMenu(params Menu[] menu) { foreach (var menuDefinition in menu) { if (MenuItemNameList.Contains(menuDefinition.Name)) { throw new Exception("Menu item name duplicated"); } Items.Add(menuDefinition); MenuItemNameList.Add(menuDefinition.Name); } }
public MenuItemBase FindMenuItem(Menu menu, string name) { if (!MenuItemNameList.Contains(name)) { return(null); } foreach (var child in menu.Children) { if (child.Name == name) { return(child); } return(FindRecursive(child, name)); } return(null); }