It is not an exaggeration to say that Dependency Injection is one of the core pillars of building modern .NET applications. It allows us to write cleaner code, both in structure but also in testability. There is a reason why since .NET Core launched (now simply .NET), it has been part of the framework and part of every codebase that is using it. It is a skill that every single .NET developer needs to master, and in this course, Nick will show you how to do just that.
Welcome
What will you learn in this course?
Who is this course for and prerequisites
The problem with dependencies
Why Dependency injection is necessary
A practical example of the dependency problem
A less obvious example of a Dependency Injection use-case
Dependency injection benefits past testability
Injecting Classes vs Abstract classes vs Interfaces
So do you have to do all that manually??
Section recap
Introduction
The simplest setup with Dependency Injection
The ServiceCollection
The ServiceProvider
All of the above, in an API
The different types of dependency lifetimes
The Transient lifetime
The Singleton lifetime
The Scoped lifetime
GetService vs GetRequiredService
Generic-based registration vs implementation-based registration
Registration approaches
The Startup.cs and changes after .NET 6
Third party libraries
Section recap
Resolving dependencies in different project types
Resolving dependencies from the constructor
Resolving dependencies from the method
Resolving dependencies in a console setup
Resolving dependencies from the HttpContext
Resolving dependencies from Action Filters as Attributes
Resolving dependencies from Service Filters
Resolving dependencies from Middleware
Resolving dependencies in Minimal APIs
Resolving dependencies in Razor Views & Pages
Resolving dependencies in Blazor
Resolving dependencies in gRPC Services
Resolving dependencies in Hosted Services
Resolving dependencies in service registration
Section recap
Do you need an interface for everything?
Choosing the right dependency lifetime
Dependency resolving issues and limitations
Registering open generics
Registering multiple interface implementations
The ServiceDescriptor
Add vs TryAdd
TryAddEnumerable
Replacing dependencies
Cleaning up service registration
Section recap
Creating a custom scope
The service locator anti-pattern
When service locator makes sense
Avoiding capturing dependencies
Avoiding multiple service providers
Creating decorators
The future of dependency injection
Section recap
What is Scrutor?
Registering service decorators
Surprise optional refactoring lecture
Service registration by scanning
Interface marking
Attribute marking
Namespace filtering
Using the ServiceDescriptor attribute
Using RegistrationStrategies
Potential pitfalls
Section recap
Why should we even bother?
The design
The implementation
Extending the main implementation
Section recap
Conclusion
Course Info
Lifetime access
Add to Cart
Nick Chapsas is a .NET & C# content creator, educator and a Microsoft MVP for Developer Technologies with years of experience in Software Engineering and Engineering Management.
He has worked for some of the biggest companies in the world, building systems that served millions of users and tens of thousands of requests per second.
Nick creates free content on YouTube and is the host of the Keep Coding Podcast.
More courses by Nick Chapsas© 2023 Dometrain. All rights reserved.