Assuming that I am using the new DepencyInjection framework to configure my classes and dependencies in the new ASP.Net/vNext.
How can I use, How can I get my pre-de
You can get AppSettings in your FooService by injecting IOptions<AppSettings>
DI service in it's constructor.
The IOptions<>
interface is part of something called Options Model which is used for accessing POCO style settings(ex: your AppSettings) across your application.
The calls like services.Configure<AppSettings>(
and services.Configure<FacebookAuthenticationOptions>(options =>
in your above example, actually register DI services which in turn are used by a DI service called OptionsManager
when resolving requests for IOptions<>
.
Example:
public class FooService
{
private readonly AppSettings _settings;
public FooService(IOptions<AppSettings> options)
{
_settings = options.Options;
}
....
....
}