/// <summary>
        /// Process a command.
        /// </summary>
        /// <param name="command">command</param>
        /// <returns>command's result</returns>
        private async Task <object> ProcessCommand(ICommand command)
        {
            var commandExecutor = _commandExecutorResolver.GetCommandExecutor(command);

            if (commandExecutor == null)
            {
                throw new CommandExecutorNotFoundException(command);
            }

            return(await commandExecutor.ExecuteAsync(command));
        }
        public async Task <TR> DispatchAsync <TR>(ICommand <TR> command)
        {
            _logger.Verbose(string.Format("Received {0}", command.GetType().Name));

            var watch = Stopwatch.StartNew();

            var commandExecutor = _commandExecutorResolver.GetCommandExecutor(command);

            if (commandExecutor == null)
            {
                throw new CommandExecutorNotFoundException(command);
            }

            var result = (TR)await commandExecutor.ExecuteAsync(command);

            watch.Stop();

            _logger.Verbose(string.Format("Took {0} ms", watch.ElapsedMilliseconds));

            return(result);
        }