In the past, I used swiftsuspenders, which is the IOC controller for ActionScript 3. Basically, the first version of switchfsuspender had something similar to the Ninject kernel, which was called an injector.
If I wanted to create an application injector (taking into account the most relevant mappings that will be used throughout the application), I would have to inject the injector into the application classes.
Now I'm wondering what is the practice of using kernel.get <> among several classes in an application. Do I have to enter the kernel myself?
Personally, I would prefer to use kernel.inject, but if I can do kernel.inject, I can really nest the dependencies manually, which is probably better (kiss).
The tests are good, but they are far from real practical questions, so I hope you can help me clarify this point. Thanks.
Edit: I noticed that some people are talking about the “root container”. It seems like this is the concept I'm looking for. How to configure the root container and let other application classes know this?
Edit2 Sample code (please forgive the errors, this is just for the sake of):
class SomeClass { public SomeClass() { Command cmd = new Command(); cmd.execute(); } } class SomeOtherClass:ISomeOtherClass { public void allright() {
I have not tested this yet because I'm still afraid of some initialization problems, but my question is, how can the team class learn about SomeOtherClass? My current hypothesis is to inject the kernel into SomeClass and use the Inject method.
inversion-of-control ninject ninject-2
sebas
source share