liveBook · Manning

BindConfiguration()

As explained in ASP.NET Core in Action, 3e

BindConfiguration() is a .NET options extension method that binds an options type to a named configuration section.

BindConfiguration() connects an options type to a named configuration section through an OptionsBuilder<T>, giving the application a strongly typed options object. section 31.2

Bind the Currencies section

builder.Services .AddOptions<CurrencyOptions>() .BindConfiguration("Currencies") .Configure(opts => opts.Currencies = new[] { "GBP", "USD" }); The builder binds the Currencies configuration section, then applies additional configuration. Injecting IOptions<CurrencyOptions> retrieves the resulting value. section 31.2

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains builder creation, section binding, additional configuration, and DI callbacks without descending into implementation internals.
Examples
Demonstrates CurrencyOptions bound to Currencies, extended with GBP and USD, and populated through an injected currency provider.
What it assumes
Assumes familiarity with C# lambdas and dependency injection while introducing the OptionsBuilder<T> registration flow.
What you can do after
Build it from scratch by registering, binding, extending, and retrieving a typed options object through dependency injection.
How it connects
Connects OptionsBuilder<T>, IOptions<T>, IConfiguration, dependency injection, Configure methods, and IConfigureOptions<T>.

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.