Example #1
0
        private async Task <CommandExecutionResult> ProcessCommand(string identity, string bodyText, CancellationToken token)
        {
            var commandHandlerVersions = Options.CommandsRegistry.GetHandlers(identity);

            foreach (var handler in commandHandlerVersions)
            {
                token.ThrowIfCancellationRequested();
                var result = await handler.Execute(bodyText);

                if (result.Status == CommandExecutionStatus.NotRecognized)
                {
                    continue;
                }

                if (result.Status == CommandExecutionStatus.ValidationFailure)
                {
                    continue;
                }

                return(result);
            }

            return(CommandExecutionResult.Undefined());
        }