AspNet Core 应用程序
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) 步骤1中的模块已在 Startup.cs
中注册。
public void ConfigureContainer(ContainerBuilder builder)
{
builder.RegisterModule(new AutofacModule());
}
如何从 AutofacModule
中访问 appsettings.json
的值?我需要在 AutofacModule
中创建对象并将其用于依赖注入。
IContainer
的方法。它不应该是IConfiguration
吗? - theyetiman