I checked the code and there is actually no support for getting the already added menu items or merging items as I can see. My guess is that "new MenuAssembler()" will create a new instance that is not connected to the one calling the menu provider so that won't help you. I talked with Cristian Libardo that developed the menu and he suggested two alternatives:
1. Use HttContext or similar so set a static flag that the top menu item has been created.
2. Add the top menu item in web.config in your nuget setup.
Thanks for the answer. I've decided to go with option 1. Everything is working fine now.
I have a small problem. I'm working on a few NuGet packages, and I need them all to appear under the same section. But I haven't been entirely successful with getting the menu to display my plugins properly. They tend to duplicate the section menu instead. So if I have 3 of my plugins installed, I'd end up with 3 duplicates of my custom section.
I'm using the MenuProvider to generate the menu items for my plugins. I first check whether the section already exists using MenuAssembler's GetMenuItems and add it using SectionMenuItem if it doesn't. However, during my debugging sessions, GetMenuItems returns 0 for all plugins. So the question is, why is it returning 0? Shouldn't the second time GetMenuItems is run return 1 as the section was added by the first plugin?
Have a look at a portion of my code below and please let me know what I did wrong.