简体   繁体   中英

What Dependency Injection Framework Does ASP.Net Core Use?

I've started dabbling in ASP.Net Core , and found out that Dependency Injection is a First-class Citizen in the ASP.Net Core framework and that it is built-in and ready to use for injecting various services and libraries.

I would like to know which Dependency Injection framework they are using. Their docs at Introduction to Dependency Injection in ASP.NET Core

ASP.NET Core is designed from the ground up to support and leverage dependency injection. ASP.NET Core applications can leverage built-in framework services by having them injected into methods in the Startup class, and application services can be configured for injection as well

Did they write their own from ground-up? Or are they re-using an existing open source Dependency Injection framework. If yes, which one?

The reason for asking, besides natural curiosity, is also that I want to use the same framework they are using in ASP.Net Core , in my .Net 4.6.1. ASP.Net Web API application.

Because I've found most DI frameworks to be very slow and bloated, even Unity .

In contrast, the ASP.Net CORE DI framework seems to be really fast and lean.

.NET Core is open source, so we can examine this for ourselves. The base repo is at:

https://github.com/dotnet/corefx

And the ASP.NET Core Repo is at:

https://github.com/aspnet/home

Going to the "DependencyInjection" Repo ( https://github.com/aspnet/DependencyInjection ) and navigating down in the source we find https://github.com/aspnet/DependencyInjection/blob/dev/src/Microsoft.Extensions.DependencyInjection/ServiceProvider.cs

Reading through that file it sure looks like a DI container. Its fair to say that Microsoft wrote their own, though they also support using existing ones according to the documentation in the Dependency Injection repo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM