Skip to content

OptionaryServiceCollectionExtensions

Classstaticnet10.0
📦 Optionary v0.1.2-beta.10
Registers strongly-typed configuration classes with the standard Extensions.Options pipeline.
namespace Optionary;
public static class OptionaryServiceCollectionExtensions
{
// ...
}

The registration method Optionary's source generator emits for [Optionary] types calls OptionaryServiceCollectionExtensions.AddOptionaryOptions for every type, passing the Create… method it generated for it. That code creates the instance and binds the section onto it without reflection, so the registration is trimming and AOT safe, and nothing here uses reflection. A library registers only its own section, and reads it from the application's complete Configuration.IConfiguration, which the service provider supplies when the options are first created.

View all methods