This is my interface:
public interface ISocialService<T> where T : ISocialModel
{
public Task<List<T>> GetPosts();
}
I have 2 implementations of this interface. This is how I try to register them
services.AddScoped<ISocialService<RedditPost>, RedditService>();
services.AddScoped<ISocialService<HackerNewsModel>, HackerNewsService>();
And finally this is how I try to resolve them.
public ScrapeJob(IEnumerable<ISocialService<ISocialModel>> socialServices)
{
_socialServices = socialServices;
}
However socialServices is empty. I think the problem lies in ISocialModel. Anyone got suggestions how can I register or resolve them properly?
The reason why I want to use a generic interface is I want to inject specific service into a controller like this:
public HackerNewsController(ISocialService<HackerNewsModel> socialService)
{
_socialService = socialService;
}