ASP.Net 核心使用什么依赖注入框架?

What Dependency Injection Framework Does ASP.Net Core Use?

我开始涉足 ASP.Net Core,发现 Dependency Injection 是 First-class Citizen 在 ASP.Net 核心框架中,它是内置的,可以用来注入各种服务和库。

我想知道他们正在使用哪个依赖注入框架。他们的文档位于 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

他们是从头开始自己写的吗?或者他们是否重新使用现有的开源依赖注入框架。如果有,是哪一个?

问这个问题的原因,除了天生的好奇之外,我还想在我的 [=11] 中使用他们在 ASP.Net Core 中使用的相同框架=] ASP.Net Web API 应用程序。

因为我发现大多数 DI 框架都非常缓慢和臃肿,甚至 Unity

相比之下,ASP.Net CORE DI 框架似乎非常快速和精简。

.NET Core是开源的,大家可以自己去考察一下。基础回购位于:

https://github.com/dotnet/corefx

ASP.NET 核心仓库位于:

https://github.com/aspnet/home

前往 "DependencyInjection" 回购(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

通读该文件,它确实看起来像一个 DI 容器。可以说微软自己写的,尽管根据依赖注入库中的文档,他们也支持使用现有的。