Contravariance? Covariance? What's wrong with this generic architecture…?
问题 I'm having some problems setting up a command handling architecture. I want to be able to create a number of different commands derived from ICommand; then, create a number of different command handlers derived from ICommandHandler; Here's the interface and classes I have begun to define: interface ICommand {} class CreateItemCommand : ICommand {} interface ICommandHandler<TCommand> where TCommand : ICommand { void Handle(TCommand command); } class CreateItemCommandHandler : ICommandHandler