MENU

Fun & Interesting

C# Dependency Injection with Autofac

IAmTimCorey 300,391 7 years ago
Video Not Working? Fix It Now

Dependency Injection in C# can be a really confusing topic. Yet, when done right, Dependency Injection can be one of the best things you do for your application. It allows you to disconnect pieces of your application from each other easily and it allows you to test the various parts of your application independently. Today, I am going to get you started using Dependency Injection using a free tool called Autofac. We will take a small sample application and first apply the Dependency Inversion Principle (the D in SOLID). Then, we will wire up Autofac to handle connecting the various dependencies together. Full courses: https://www.iamtimcorey.com/ Source Code: https://leadmagnets.app/?Resource=DependencyInjection Patreon: https://patreon.com/IAmTimCorey Newsletter signup: https://signup.iamtimcorey.com/ Sponsors: Tuhafeni Angula (Patreon Subscriber) 0:00 - Intro 1:17 - Demo code overview 5:00 - Refactoring demo code 9:19 - Implementing Autofac: Adding the reference 10:28 - Implementing Autofac: Setup 26:39 - Implementing Autofac: Code explained 33:21 - Recap 36:43 - Why to... : Unit Test 40:33 - Why to... : Changing the code 48:31 - Summary 50:29 - Concluding remarks

Comment