【发布时间】:2018-07-23 06:52:22
【问题描述】:
AspNet 核心应用程序
1) 这样的 Autofac 模块
public class AutofacModule : Module
{
protected override void Load(ContainerBuilder builder)
{
//Register my components. Need to access to appsettings.json values from here
}
}
2) step№1 中的模块注册到Startup.cs
public void ConfigureContainer(ContainerBuilder builder)
{
builder.RegisterModule(new AutofacModule());
}
如何从AutofacModule 访问appsettings.json 值?我需要它来在 AutofacModule 中创建我的对象并将其用于 DI。
【问题讨论】:
标签: dependency-injection .net-core autofac autofac-module