-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.cs
23 lines (20 loc) · 878 Bytes
/
Settings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using Microsoft.Extensions.Configuration;
public class Settings
{
public string? ClientId { get; set; }
public string? TenantId { get; set; }
public static Settings LoadSettings()
{
// Load settings
IConfiguration config = new ConfigurationBuilder()
// appsettings.json is required
.AddJsonFile("appsettings.json", optional: false)
// appsettings.Development.json" is optional, values override appsettings.json
.AddJsonFile($"appsettings.Development.json", optional: true)
// User secrets are optional, values override both JSON files
.AddUserSecrets<Program>()
.Build();
return config.GetRequiredSection("Settings").Get<Settings>() ??
throw new Exception("Could not load app settings. See README for configuration instructions.");
}
}