You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.
services.AddSingleton<IConfigureOptions<MvcOptions>, MyConfigureMvcOptions>() seems unwieldy and non-obvious. I believe a friendlier, more discoverable alternative would be services.Configure<MvcOptions, MyConfigureMvcOptions>().
public static IServiceCollection Configure<TOptions, TConfigureOptions>(this IServiceCollection services)
where TOptions : class
where TConfigureOptions : class, IConfigureOptions<TOptions>
{
return services.AddSingleton<IConfigureOptions<TOptions>, TConfigureOptions>();
}
public static IServiceCollection Configure<TOptions, TPostConfigureOptions>(this IServiceCollection services)
where TOptions : class
where TPostConfigureOptions: class, IPostConfigureOptions<TOptions>
{
return services.AddSingleton<IPostConfigureOptions<TOptions>, TPostConfigureOptions>();
}
The text was updated successfully, but these errors were encountered:
We used to have sugar for this early in 1.0 which we removed near 1.0 RTM, we actually allowed registration of a global setup class, and would reflect on it registering all IConfigureOptions it implemented.
i.e.
services.RegisterOptionsSetup<MyConfigure>(); // Reflects and registers all of the appropriate
class MyConfigure : IConfigureOptions<MvcOptions>, IConfigureOptions<RazorOptions>, IPostConfigureOptions<MvcOptions> {
// implement everything you want in one class
}
services.AddSingleton<IConfigureOptions<MvcOptions>, MyConfigureMvcOptions>()
seems unwieldy and non-obvious. I believe a friendlier, more discoverable alternative would beservices.Configure<MvcOptions, MyConfigureMvcOptions>()
.The text was updated successfully, but these errors were encountered: