I’ve got the following code:
interface IActionHandler<in T> where T : IAction
{
Status Execute(T action);
}
class SoftwareActionHandler : IActionHandler<SoftwareAction>
{
public Status Execute(SoftwareAction action)
{
//implementation
}
}
There are of course a few more implementations of IActionHandler<>
.
Now when it comes to registering them in MS DI how would I go about doing that? Because of contravariance I can’t just do:
services.AddSingleton<IActionHandler<IAction>>, SoftwareActionHandler>();
1