I'm preparing to use Dependency Injection using Microsoft.Extensions.DependencyInjection
for the first time.
So I've been reading on it and apparently all examples I've seen regarding getting a concrete implementation of an interface involves a factory that will get injected either a func<IEnumerable<TInterface>>
or IEnumerable<TInterface>
and involves instancianting all implementations to search and return a specific implementation.
This doesn't sound too bad if there are very few implementations and all of them are light, which they are in all examples I've seen - but examples are not real use cases, but what if this is not the case?
Is this really the only option?
Everytime I need to inject ImplementationN
of TInterface
it instanciates all implementations of TInterface
?