Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.43 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Where is the control inverted in Inversion of Control
  2. Class car
  3. {
  4.   Engine _engine;
  5.    Public Car()
  6.    {
  7.        _engine = new V6();
  8.    }
  9. }
  10.        
  11. Class car
  12. {
  13.    Engine _engine;
  14.     Public Car(Engine engine)
  15.     {
  16.         _engine = engine;
  17.      }
  18. }
  19.  
  20. var car = new Car(new V4());
  21.        
  22. IUserRepository _user  = new UserRepository();
  23. //you're in control of which instance is created.
  24.        
  25. IUserRepository _user;// you will not do anything else.