Autoplay
Autocomplete
Previous Lesson
Complete and Continue
From Zero to Hero: Dependency Injection in .NET with C#
Course overview
Welcome (2:34)
What will you learn in this course? (1:49)
Who is this course for and prerequisites (1:21)
Introduction to Dependency Injection
The problem with dependencies (6:47)
Why Dependency injection is necessary (5:13)
A practical example of the dependency problem (10:25)
A less obvious example of a Dependency Injection use-case (4:24)
Dependency injection benefits past testability (1:11)
Injecting Classes vs Abstract classes vs Interfaces (1:51)
So do you have to do all that manually?? (1:21)
Section recap (1:09)
Dependency Injection fundamentals in .NET
Introduction (0:38)
The simplest setup with Dependency Injection (6:34)
The ServiceCollection (2:00)
The ServiceProvider (1:46)
All of the above, in an API (5:27)
The different types of dependency lifetimes (4:30)
The Transient lifetime (2:08)
The Singleton lifetime (2:08)
The Scoped lifetime (2:31)
GetService vs GetRequiredService (3:38)
Generic-based registration vs implementation-based registration (3:31)
Registration approaches (6:04)
The Startup.cs and changes after .NET 6 (2:09)
Third party libraries (1:49)
Section recap (1:09)
Resolving dependencies
Resolving dependencies in different project types (0:21)
Resolving dependencies from the constructor (0:59)
Resolving dependencies from the method (1:27)
Resolving dependencies in a console setup (1:17)
Resolving dependencies from the HttpContext (1:09)
Resolving dependencies from Action Filters as Attributes (2:42)
Resolving dependencies from Service Filters (2:42)
Resolving dependencies from Middleware (2:32)
Resolving dependencies in Minimal APIs (3:13)
Resolving dependencies in Razor Views & Pages (1:28)
Resolving dependencies in Blazor (1:00)
Resolving dependencies in gRPC Services (1:16)
Resolving dependencies in Hosted Services (2:38)
Resolving dependencies in service registration (1:54)
Section recap (0:31)
Deep dive
Do you need an interface for everything? (4:59)
Choosing the right dependency lifetime (2:31)
Dependency resolving issues and limitations (7:43)
Registering open generics (2:38)
Registering multiple interface implementations (3:22)
The ServiceDescriptor (4:22)
Add vs TryAdd (4:22)
TryAddEnumerable (3:31)
Replacing dependencies (5:47)
Cleaning up service registration (3:22)
Section recap (0:59)
Advanced techniques
Creating a custom scope (5:42)
The service locator anti-pattern (2:48)
When service locator makes sense (20:37)
Avoiding capturing dependencies (3:14)
Avoiding multiple service providers (3:18)
Creating decorators (7:11)
The future of dependency injection (3:55)
Section recap (0:47)
Extending Dependency Injection with Scrutor
What is Scrutor? (1:34)
Registering service decorators (3:58)
Surprise optional refactoring lecture (8:26)
Service registration by scanning (13:09)
Interface marking (3:28)
Attribute marking (3:13)
Namespace filtering (2:19)
Using the ServiceDescriptor attribute (2:47)
Using RegistrationStrategies (2:24)
Potential pitfalls (1:52)
Section recap (0:46)
Creating our own Dependency Injection framework
Why should we even bother? (1:25)
The design (2:57)
The implementation (19:57)
Extending the main implementation (10:36)
Section recap (0:33)
Conclusion
Conclusion (0:32)
Rate this course
What will you learn in this course?
Complete and Continue