How do I inject the type of a class into one of its dependencies using the built in ASP.Net dependency injection?
In Startup.Configure I have:
services.AddTransient<ILogger>(x => new Logger(???));
And my class takes a Logger instance
public class ExampleController : ControllerBase
{
public Example(ILogger logger)
{
...
}
}
The Logger constructor should receive typeof(Example) where I have written "???", except this should work for all classes that receive a logger.
The question is very similar to this but I am using an in-house ILogger interface and Logger class, and not using ninject. I effectively wan't to duplicate ninject's "context.Request.ParentContext.Plan.Type" in the other question.