c# in 20 minutes: dependency injection
DESCRIPTION
A brief introduction into dependency injection with C#. Due to the complexity the 20 minute talk just scratches at the surface.TRANSCRIPT
![Page 1: C# in 20 Minutes: Dependency Injection](https://reader036.vdocuments.mx/reader036/viewer/2022082410/553ab6a2550346e2498b45ce/html5/thumbnails/1.jpg)
C# in 20 MinutesDependency Injection
Thomas Mentzelblog.softwarekueche.de
![Page 2: C# in 20 Minutes: Dependency Injection](https://reader036.vdocuments.mx/reader036/viewer/2022082410/553ab6a2550346e2498b45ce/html5/thumbnails/2.jpg)
How to explain dependency injection to a 5-year old?
• When you go and get things out of the refrigerator for yourself, you can cause problems. You might leave the door open, you might get something Mommy or Daddy doesn't want you to have. You might even be looking for something we don't even have or which has expired.
• What you should be doing is stating a need, "I need something to drink with lunch," and then we will make sure you have something [proper] when you sit down to eat.
StackOverflow (http://bit.ly/1mBlD78)
![Page 3: C# in 20 Minutes: Dependency Injection](https://reader036.vdocuments.mx/reader036/viewer/2022082410/553ab6a2550346e2498b45ce/html5/thumbnails/3.jpg)
TemplateEditor right now…
![Page 4: C# in 20 Minutes: Dependency Injection](https://reader036.vdocuments.mx/reader036/viewer/2022082410/553ab6a2550346e2498b45ce/html5/thumbnails/4.jpg)
…refactors to Interfaces…
![Page 5: C# in 20 Minutes: Dependency Injection](https://reader036.vdocuments.mx/reader036/viewer/2022082410/553ab6a2550346e2498b45ce/html5/thumbnails/5.jpg)
… and ends up withDependency Injection
![Page 6: C# in 20 Minutes: Dependency Injection](https://reader036.vdocuments.mx/reader036/viewer/2022082410/553ab6a2550346e2498b45ce/html5/thumbnails/6.jpg)
Dependency Injection Container
![Page 7: C# in 20 Minutes: Dependency Injection](https://reader036.vdocuments.mx/reader036/viewer/2022082410/553ab6a2550346e2498b45ce/html5/thumbnails/7.jpg)
Injection Methods
• Constructor Injection– constructor parameter– required dependencies
• Property Injection– properties/setter– optional parameter– null-object pattern
![Page 8: C# in 20 Minutes: Dependency Injection](https://reader036.vdocuments.mx/reader036/viewer/2022082410/553ab6a2550346e2498b45ce/html5/thumbnails/8.jpg)
Supportive Frameworks
• Caliburn Micro for WPF
• ASP.NET MVC Built-In
• Prism for Silverlight• …and many many more
![Page 9: C# in 20 Minutes: Dependency Injection](https://reader036.vdocuments.mx/reader036/viewer/2022082410/553ab6a2550346e2498b45ce/html5/thumbnails/9.jpg)
You should know …
• … what Dependency Injection is
• … what a DI Container is• … what the difference between
Constructor Injection and Property Injection is
• … what inversion of control means• … when to use Dependency Injection
![Page 10: C# in 20 Minutes: Dependency Injection](https://reader036.vdocuments.mx/reader036/viewer/2022082410/553ab6a2550346e2498b45ce/html5/thumbnails/10.jpg)
Fragen?!
• Thomas Mentzel• blog.softwarekueche.de• [email protected]
• @ThomasMentzel
• Google: Thomas Mentzel, Hennef