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")); | |
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 MySettingsValidator : IPostConfigureOptions<MySettings> | |
| { | |
| public void PostConfigure(string name, MySettings options) | |
| { | |
| if (options.Validate()) | |
| { | |
| return; | |
| } | |
| throw new InvalidOperationException($"Invalid {nameof(MySettings)} options. {string.Join(",", options.ValidationResult)}"); |
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 abstract class Repository | |
| { | |
| protected string ConnectionString { get; } | |
| protected Repository(IConfiguration configuration) | |
| { | |
| ConnectionString = configuration.GetConnectionString("DefaultConnection"); | |
| } | |
| // ... código omitido |
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
| [Route("api/[controller]")] | |
| public class HomeController : Controller | |
| { | |
| public HomeController(IOptions<MySettings> settings) | |
| { | |
| var applicationName = settings.Value.ApplicationName; | |
| var author = settings.Value.Author; | |
| } | |
| } |
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 | |
| { | |
| public IConfiguration Configuration { get; } | |
| // ... código omitido | |
| public void ConfigureServices(IServiceCollection services) | |
| { | |
| services.AddSingleton(Configuration); | |
| services.Configure<MySettings>(Configuration.GetSection("MySettings")); |
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 MySettings | |
| { | |
| public string ApplicationName { get; set; } | |
| public string Author { get; set; } | |
| } |
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 HomeController(IConfiguration configuration) | |
| { | |
| var applicationName = configuration.GetValue<string>("MySettings:ApplicationName"); | |
| var logLevel = configuration.GetValue<string>("Logging:LogLevel:Default"); | |
| } |
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
| var configuration = new ConfigurationBuilder() | |
| .SetBasePath(Directory.GetCurrentDirectory()) | |
| .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) | |
| .Build(); |
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
| { | |
| "JwtSettings": { | |
| "Issuer": "DemoJwtApi", | |
| "Audience": "demo-jwt-api", | |
| "SigningKey": "kzfSPDKwdx5KnyxtBTlwNW_IoqrpbaGRwaFNdqxQyv-WVIqeLKOGJVLmh4lRd4wUPmolq6CM7Bs4r1NRbAoZQZQui80YbqMGuymdw5NSlnMvoMHNdF2niiydKV5X2esajAZk6t1pu1Jf05TNIxQBO1aI8xnk4ttVIPXRDG47wKlTPwnvqpVX3lh5nwrG_A4fUj7KOslfysPbusORDePIQlnnCqkzURl3qanQzjku02kWxujqpujl3I1VpJ0zKc2ReeyVNoeKNG3WYi2eO8sYsDw8XtbkcY5mJW7dHeXSMYvzrFIWDbbxorb5LP0FtFbsgOfh8IYT4qzSL4BmUV17ag", | |
| "ValidForMinutes": 60, | |
| "RefreshTokenValidForMinutes": 120 | |
| } | |
| } |
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
| [Route("api/[controller]")] | |
| public class AccountsController : Controller | |
| { | |
| private readonly IMediator _mediator; | |
| public AccountsController(IMediator mediator) | |
| { | |
| _mediator = mediator; | |
| } | |