, ASPNET Core, web.config.
.
IOptions<FooSettingsClass> , , , .
// Adds services required for using options.
services.AddOptions();
services.Configure<AppSettings>(Configuration.GetSection("FooAppSettings"));
- . , , ( ) :
class FooController : Controller {
public FooController(IOptions<FooSettingsClass> settings) { .
}
}
, , , , . :
public class SomeServiceInAnotherAssembly {
public SomeServiceInAnotherAssembly(IOptions<FooSettingsClass> settings) {
}
}
, , , FooSettingsClass ASPNET Core ( ), - , . - , .
, ( SomeServiceInAnotherAssembly) , .. services.AddScoped<SomeServiceInAnotherAssembly>();
, .