I'd like to have a class that works as a collection for another class. So let's say I have FooBarCollection that has a collection of named FooBarItems. I can bind the FooBarCollection and injecting it works. The problem is that in order to keep things tidy, I'd want to do one injection within the FooBarItem class too, but in order for that to work I'd need to use a DiContainer for the instantiation, and that has too problems:
- I can't do the DiContainer-based instantiation in the same line where I define the field, so I'd need two lines of code for each item in the collection. I'd like to avoid this kind of redundancy, and depending on remembering both lines of code to be added for every single item.
- Passing parameters to the DiContainer instantiation isn't type-sensitive.
So is there some way that:
- I could use Zenject for to inject the FooBarCollection
- Have each FooBarItem under FooBarCollection to be added with a single line of code, while still being able to inject one dependency in the FoobarItem ?
Any ideas?