Skip to content
0:00 / 0:00

#dependencyinjection#ioccontainer#c#

Trying to create a Dependency Injection/IoC Container FROM SCRATCH

Nick Chapsas

429K subscribers • 62 videos on Hallway

YouTube
  • Recommended by 3 people: 3 in engineering communities.
  • A classic. People kept recommending it from 2021 to 2024.
  • Presented by Nick Chapsas

Advanced. Deep dive for people who know the field.

51K views6 years ago3 recommendations

Software designProgramming languagesDesign patternsC# and .NET

Nick Chapsas demonstrates how to build a custom dependency injection and inversion of control container from scratch using C#.

Become a Patreon and get source code access: patreon.com/nickchapsas Check out my courses: dometrain.com Hello everybody I'm Nick and in this video I will try to create a dependency injection or DI container from scratch. This is also known as an IoC container or an inversion of control container. I'm going to do that using C# and .NET Core 3. In object-oriented design, the dependency inversion principle is a specific form of decoupling software modules. When following this principle, the conventional dependency relationships established from high-level, policy-setting modules to low-level, dependency modules are reversed, thus rendering high-level modules independent of the low-level module implementation details. Don't forget to comment, like and subscribe :) Social Media: Follow me on GitHub: bit.ly/ChapsasGitHub Follow me on Twitter: bit.ly/ChapsasTwitter Connect on LinkedIn: bit.ly/ChapsasLinkedIn

Why it's here

3 people recommend this

What people say. Recommended as an educational exercise to understand how dependency injection containers work under the hood.

u/syutzyin r/dotnet • Recommends

On “Implementing DI container”

If what you mean is "how to use the built-in DI container in .NET core", you might start here: https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection If what you mean is "I want to write my own container from scratch" (which is probably not a good idea for production, but could be a fun learning exercise), you might start here: [video (Nick Chapsas video)

u/stuartseupaulin r/dotnet • Recommends

On “How to understand the fundamentals better?”

For something like dependency injection, look up a video on how to code a version of it from scratch. I haven't watched this video myself but it looks decent enough. link to this video For middleware, I think the docs should be sufficient. https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-9.0

u/AussieBoy17in r/dotnet • Recommends

On “Scouped Services, creating newly on every request without pool?”

…how it is implemented without actually seeing the source code. It's been a while since I have watched this video, but this guy does some really good videos and this is a video of him going through making his own DI container. Note, the .Net DI container is going to be a lot more complicated with things like caching, but the concept is the same. [video >I've never seen Lifetime concept from them Here's my best attempt to explain the differences. **Host** In .Net, our DI providers are inside a 'host'. I think of this almost like a mini program inside your program. It's meant to be pretty much isolated in its own little bubble. The Host creates the root Service Provider which is what is…