Search

Categories

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Send mail to the author(s) E-mail

# Monday, 20 January 2014
( IoC | Unity | Windsor )

http://simpleprogrammer.com/

Maybe this will be a simple way forward for the Winter Project?  He is principally using Unity.

http://pluralsight.com/training/Courses/Description/ioc-aspdotnet-mvc4

image

 

image

we can make our own controller Factory

image

Also likely that we’ll want to inject into our views.  ViewResult comes back from an Action.

Basics

image
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..

Most Popular

  • Ninject 1
  • Unity 2 (MS implementation)

image

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.

Container

  • 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.

image

image

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

| | #