Maybe this will be a simple way forward for the Winter Project? He is principally using Unity.
we can make our own controller Factory
Also likely that we’ll want to inject into our views. ViewResult comes back from an Action.
Want to invert the normal control classes have on their dependencies
ie nomally if we new up a class within another class, then this ‘dependency’ is problematic
- Higher level classes are affected by lower level
eg if create instance of Laptop, we’d need to create instances of Battery, WallOutlet and SolarCell.
- Our laptop is dependant on the IPowerSource interface
- But how to create an instance of laptop and have battery, walloutlet etc..
- Ninject 1
- Unity 2 (MS implementation)
We can do this manually with Constructor based DI, but tedious and if some of power sources had their own dependencies, then complex and error prone.
- Tell which Interfaces are mapped to which implementations
- Resolve them for us
- eg IpowerSource should be mapped to battery class
- When ask IoC container for instance of our laptop class
- it will automatically construct laptop class with battery dependency passed in.
Therefore we need to hook into the correct part of MVC pipeline.
Windsor in here.
running as admin didn’t work
Found that if I saved the app on an AltF4, then reloaded (with DA off) it worked.
Controller Factory vs Dependency Resolver
Going to use DR as using Filter injection