Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save wellingtonjhn/58116c42791ed61db9bffdca9a867367 to your computer and use it in GitHub Desktop.

Select an option

Save wellingtonjhn/58116c42791ed61db9bffdca9a867367 to your computer and use it in GitHub Desktop.
Startup PostConfigure Method implementation
public class Startup
{
// ... código omitido
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton(Configuration);
services.Configure<MySettings>(Configuration.GetSection("MySettings"));
services.PostConfigure<MySettings>(options =>
{
if (!options.Validate())
{
throw new InvalidOperationException($"Invalid {nameof(MySettings)} options. {string.Join(",", options.ValidationResult)}");
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment