简体   繁体   English

ASP.NET Core:依赖注入——类似于 autofac 模块

[英]ASP.NET Core: dependency injection — analogue of autofac modules

I'm configuring DI container to be able to resolve several services inside my app.我正在配置 DI 容器,以便能够解析我的应用程序内的多个服务。
If I would have used autofac, I would use modules from there to logically bundle registrations.如果我使用 autofac,我会使用那里的模块来逻辑地捆绑注册。
Does ASP.NET core framework has analogues for modules? ASP.NET 核心框架是否有模块的类似物? How can I achieve that if I want?如果我愿意,我怎样才能做到这一点?

Official doc on DI says: DI 的官方文档说: 在此处输入图片说明 Does that mean that I shouldn't be looking for module system anymore?这是否意味着我不应该再寻找模块系统了? And if I have like 20-50 services, it's best to create an extension for each separate one?如果我有 20-50 个服务,最好为每个单独的服务创建一个扩展?

AFAIK there is nothing comparable to autofac's modules registration in the core DI implementations. AFAIK 在核心 DI 实现中没有什么可以与 autofac 的模块注册相媲美。 You would have to implement it on your own, which should not become a really big deal.您必须自己实现它,这不应该成为一个真正的大问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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