concept IOptions in category asp.net

appears as: IOptions, IOptions
ASP.NET Core in Action

This is an excerpt from Manning's book ASP.NET Core in Action.

Listing 11.9. Injecting strongly typed options into a controller using IOptions<T>
public class HomeController : Controller { public HomeController(IOptions<HomePageSettings> options) #1 { HomePageSettings settings = options.Value; #2 var title = settings.Title; #3 var showCopyright = settings.ShowCopyright; #4 } } #1 You can inject a strongly typed options class using the IOptions<> wrapper interface. #2 The Value property exposes the POCO settings object. #3 The settings object contains properties that are bound to configuration values at runtime. #4 The binder can also convert string values directly to primitive types. !@%STYLE%@! {"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":2,\"ch\":67},{\"line\":2,\"ch\":69}],[{\"line\":10,\"ch\":0},{\"line\":10,\"ch\":2}],[{\"line\":4,\"ch\":67},{\"line\":4,\"ch\":69}],[{\"line\":11,\"ch\":0},{\"line\":11,\"ch\":2}],[{\"line\":5,\"ch\":67},{\"line\":5,\"ch\":69}],[{\"line\":12,\"ch\":0},{\"line\":12,\"ch\":2}],[{\"line\":6,\"ch\":67},{\"line\":6,\"ch\":69}],[{\"line\":13,\"ch\":0},{\"line\":13,\"ch\":2}]]"} !@%STYLE%@!

There’s one catch with this setup: you can’t use the reloadOnChange parameter I described in section 11.2.3 to reload your strongly typed options classes when using IOptions<T>. IConfigurationRoot will still be reloaded if you edit your appsettings.json files, but it won’t propagate to your options class.