コード例 #1
0
        public void Execute(ConsoleModeContext ctx)
        {
            SetupLanguage();
            _tasks = _consoleTaskLocator.GetTaskHolderList();
            ctx.TaskList.Clear();
            ctx.TaskList.AddRange(_tasks);
            ctx.TaskList.ForEach(th => th.Task.Context = ctx);

            var currentTasks = _tasks;
            var pageInfo     = SetupPageInfo(currentTasks);

            _lastTask = null;
            _lastData = null;

            while (true)
            {
                UtilConsole.Clear();
                ShowWelcomeMessage();
                ShowTasks(currentTasks, pageInfo);
                Console.Write("Select task :>");
                var opt = Console.ReadLine();
                if (string.IsNullOrWhiteSpace(opt))
                {
                    currentTasks = _tasks;
                    pageInfo     = SetupPageInfo(currentTasks);
                    continue;
                }

                CommonTaskHolder selectedTask = null;

                var askForData = true;
                if (opt == "!")
                {
                    if (_lastTask != null)
                    {
                        selectedTask = _lastTask;
                    }
                }
                else if (opt == "!!")
                {
                    if (_lastTask != null)
                    {
                        selectedTask = _lastTask;
                    }
                    askForData = false;
                }
                else if (Regex.IsMatch(opt, "^!\\d+$"))
                {
                    var favoriteMacroKey = opt[1..];