OptionsBuilder<T> provides a fluent way to create and configure strongly typed IOptions<T> objects. Start with AddOptions<T>(), then chain calls such as BindConfiguration and Configure to combine configuration binding with code-based settings. section 31.2 section 31.4
Bind configuration and add code-based settings
builder.Services .AddOptions<CurrencyOptions>() .BindConfiguration("Currencies") .Configure(opts => opts.Currencies = new[] { "GBP", "USD" }); When a dependent service requests IOptions<CurrencyOptions>, the framework creates the options object, applies the registered configuration steps, and exposes the result through opts.Value. section 31.2 section 31.2
OptionsBuilder<T> can resolve dependencies from dependency injection while running a configuration action. Register the dependency, then use a Configure<TDependency> overload to populate the options from that service. For more separation, implement IConfigureOptions<T> and inject the dependency into its constructor. The builder also supports options validation. section 31.2 section 31.4
