예제 #1
0
        private Task ProcessContextAsync(Input input, CommandContext context, CancellationToken cancellation)
        {
            object command = commandManagement.BuildCommand(context.Key);

            context.CancellationToken = cancellation; // TODO: [P2] Should not to be here

            switch (command)
            {
            case ICommand typedCommand:
                return(ProcessTypedCommandAsync(typedCommand, context, input, cancellation));

            default:
                return(ProcessUnknownCommandAsync(command, context, input, cancellation));
            }
        }
예제 #2
0
        public async Task <IEnumerable <IItem> > GetHelpAsync(Input input)
        {
            IEnumerable <IItem> helpItems = Enumerable.Empty <IItem>();
            object command = commandManagement.BuildCommand(input.Context.Key);

            if (command == null)
            {
                return(helpItems);
            }

            switch (command)
            {
            case IIntellisenseProvider asynchronousProvider:
                helpItems = await asynchronousProvider.GetHelpAsync(input);

                break;

            case ISynchronousIntellisenseProvider synchronousProvider:
                helpItems = synchronousProvider.GetHelp(input);
                break;
            }

            return(helpItems.Take(MAXIMUM_ITEMS_COUNT));
        }