-
Notifications
You must be signed in to change notification settings - Fork 152
Description
SimpleInjector registration binds a particular service type to a concrete class. If I have a whole group of classes that are in the "leaves" of the dependency tree, ie. they depend on other services, but they themselves do not provide any service, then I'm forced to resolve dependencies manually by using the container as a service locator - not the best option!
In my particular problem, I can create a group of classes using reflection. These classes share some common properties, but they don't implement some common interface. So, it would be great if:
- I could pass a collection of these class types to a SimpleInjector container, to create an instance of each and inject whatever dependencies they have.
- Later on, retrieve these created instances to perform some shared operation over them. Even if I could only get a collection of all instances SimpleInjector container created, I could test them to find the ones I'm interested in.
Is this possible in the current SimpleInjector implementation? Does this use case somehow violate principles that SimpleInjector is based on?
I know I could define an empty interface and have all my classes "implement" it, but it looks like more of a hack to compensate for the lack of before mentioned features.