Example #1
0
        public MainMenu AddSubMenu(SubMenu subMenu)
        {
            if (string.IsNullOrEmpty(subMenu.Name))
            {
                throw new ArgumentNullException(nameof(subMenu.Name), "No name set for submenu.");
            }

            subMenu.SetRoot(this);
            _subMenus.Add(subMenu.Name, subMenu);
            return(this);
        }
Example #2
0
        public void Select(string name, string path = null)
        {
            if (name == null)
            {
                name = string.Empty;
            }

            if (!_subMenus.TryGetValue(name, out var subMenu))
            {
                throw new InvalidOperationException($"Cannot find a menu with name '{name}'.");
            }

            _selectedMenu = subMenu;
            _selectedMenu.Select(path);
        }
Example #3
0
 public MainMenu(Func <NodeBase, string, Task <HandlerResult> > defaultHandler = null)
 {
     _selectedMenu = new SubMenu(string.Empty, defaultHandler);
     _selectedMenu.SetRoot(this);
     _subMenus.Add(_selectedMenu.Name, _selectedMenu);
 }