How to resolve un-registered type using standard MVC Core dependency injection

asked9 years ago
last updated8 years ago
viewed5.3k times
Up Vote28Down Vote

Is there a way to get IServiceProvider.GetService<T> to return an instance even if T is not explicitly registered with the container?

If I know that T has dependencies I'd like them to be injected based on their registrations without having to register T itself.

I believe Ninject will intelligently work out the most appropriate constructor or fallback to a parameterless constructor if no suitable constructor is found. I'd like to replicate this behaviour using the standard MVC Core DI framework if possible.