options pattern

Binding a configuration section to a plain class with typed properties, validating it, and injecting it into services instead of reading raw strings.

In more detail

Bound once and validated at startup, a bad setting stops the host instead of failing a request in production. Services receive it through IOptions<T>, IOptionsSnapshot<T> or IOptionsMonitor<T>.

Example

public sealed class CatalogOptions { public const string SectionName = "Catalog"; }

Related terms

Taught in

References