Example #1
0
        public PostInvokeCommand Invoke()
        {
            this.SetEmptyMenuReturnCommand(false);
            MenuOptionKey?selectedOption = null;

            while (true)
            {
                selectedOption = MenuOptionKeyService.GetOptionKey(this.Label, this._optionses.ToReadOnly(), selectedOption, true);
                if (selectedOption is null)
                {
                    return(PostInvokeCommand.StayInSubmenu);
                }
                switch (this._optionses[selectedOption.Value].Invoke())
                {
                case PostInvokeCommand.StayInSubmenu:
                    continue;

                case PostInvokeCommand.ExitSubmenu:
                    return(PostInvokeCommand.StayInSubmenu);

                case PostInvokeCommand.ExitRootMenu:
                    return(PostInvokeCommand.ExitRootMenu);

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
Example #2
0
        public void InvokeAsRootMenu()
        {
            this.SetEmptyMenuReturnCommand(true);
            MenuOptionKey?selectedOption = null;

            while (true)
            {
                selectedOption = MenuOptionKeyService.GetOptionKey(this.Label, this._optionses.ToReadOnly(), selectedOption, false);
                if (this._optionses[selectedOption.Value].Invoke() == PostInvokeCommand.ExitRootMenu)
                {
                    return;
                }
            }
        }