Microsoft.Extensions.Options.Contextual is a little-known, still-experimental .NET package that allows configuring options objects dynamically based on a runtime context object. The setup involves marking a context class with [OptionsContext] to trigger a source generator, implementing an IOptionsContextReceiver to extract

12m read timeFrom andrewlock.net
Post cover image
Table of contents
What is Microsoft.Extensions.Options.Contextual?Configuring options based on another typeAdding the Microsoft.Extensions.Options.Contextual packageConfiguring the contextual optionsSo, what's this for again?Feature flags, theoreticallyDefinitely experimentalSummary

Sort: