This article talks about how to register Generic interfaces in .Net Core. However I have a generic interface which has multiple arguments and am having trouble figuring out registeration and constructor injection.
My Interface has 4 arguments
public class TestImplementation
{
// Try to inject IRepository here ??????
public TestImplementation(.......)
{
...
}
}
public class Repository : IRepository<Test1, Test2, Test3, Test4>
{
...
}
public interface IRepository<T, U, V, W> where T : ITemplate1 where U : ITemplate2,...
{
...
}
If I try to inject the Interface to any class, it gives me error as the interface doesnt get resolved even using below code in other part of the code
services.GetService(typeof(IRepository<,,,>))
I tried using constructor injection but it makes compiler unhappy (Unable to resolve service for type '....Interface....' while attempting to activate xxxx) as I want to keep the Interface open. I however resolve the interface in the code