Last active
August 30, 2018 06:33
-
-
Save wellingtonjhn/58116c42791ed61db9bffdca9a867367 to your computer and use it in GitHub Desktop.
Startup PostConfigure Method implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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