public bool InsertMenuItemAt(AdminNode menuItemToInsert, AdminNode destinationMenuItem, int position) { if (menuItemToInsert == null) { throw new ArgumentNullException("menuItemToInsert"); } // insert the node at the destination node if (destinationMenuItem == null) { MenuItems.Insert(position, menuItemToInsert); return(true); // success } else { foreach (var firstLevelMenuItem in MenuItems) { if (firstLevelMenuItem.InsertMenuItem(menuItemToInsert, destinationMenuItem, position)) { return(true); // success } } } return(false); // failure }
public bool RemoveMenuItem(AdminNode itemToRemove) { if (MenuItems.Contains(itemToRemove)) // todo: avoid this check by having a single TreeNode as a property of the content tree preset. { MenuItems.Remove(itemToRemove); return(true); // success } else { foreach (var firstLevelMenuItem in MenuItems) { if (firstLevelMenuItem.RemoveMenuItem(itemToRemove)) { return(true); // success } } } return(false); // failure }