Register a generic service in .Net core
public interface IService<T>
{
async Task DoAction();
}
public class Service<T> : IService<T>
{
public async Task DoAction()
{
.... do action
}
}
ServiceCollection.AddScoped<typeof(IService<>), typeof(Service<>)>();
ServiceCollection.AddScoped<typeof(ITInterface<>), typeof(TImplement<>)>(typeof(Service<>));
ServiceCollection.AddScoped(typeof(TImplement<>));