public Task ExecuteAsync <TCommand>(TCommand command) where TCommand : ICommand { if (command == null) { throw new ArgumentNullException("command"); } if (!command.Validate(_validationContext)) { throw new ValidationErrorException(_validationContext.FormatValidationError()); } var handler = _provider.GetService(typeof(ICommandHandler <TCommand>)); if (handler == null) { throw new CommandHandlerNotFoundException(); } return((handler as ICommandHandler <TCommand>).ExecuteAsync(command)); }