コード例 #1
0
        public ActionResult SelectMenuItem(MenuItem menuItem)
        {
            var errorMessage = string.Empty;

            if (!GetCurrentItems().Contains(menuItem))
            {
                return(FailResult.Get($"Menu item not found"));
            }

            try
            {
                switch (menuItem)
                {
                case CommandMenuItem command:
                    var cmdParams   = command.GetParameters();
                    var paramValues = ReadParams(cmdParams);
                    return(command.Execute(paramValues));

                default:
                    currentItem = menuItem;
                    return(OkMenuResult.Get());
                }
            }
            catch (Exception ex)
            {
                errorMessage            = ex.Message;
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Something goes wrong");
                Console.ResetColor();
            }

            return(FailResult.Get(errorMessage));
        }
コード例 #2
0
        public ActionResult NavigateTo(MenuItem menuItem)
        {
            if (Items.Contains(menuItem))
            {
                return(OkMenuResult.Get());
            }

            var message = $"Wrong menu item '{menuItem.Name}'";

            return(FailResult.Get(message));
        }
コード例 #3
0
        public ActionResult Execute(string[] values)
        {
            var prmValues = BuildParameterValues(values, out var errorMessages);

            if (!string.IsNullOrWhiteSpace(errorMessages))
            {
                return(FailResult.Get(errorMessages));
            }

            return(InnerExecute(prmValues));
        }