Created
February 21, 2017 22:18
-
-
Save anonymous/a094675c112e57031fefe750f551a510 to your computer and use it in GitHub Desktop.
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 Program | |
{ | |
public static void Main(string[] args) | |
{ | |
var builder = new ConfigurationBuilder() | |
.SetBasePath(Directory.GetCurrentDirectory()) | |
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) | |
.AddEnvironmentVariables(); | |
IConfigurationRoot configuration = builder.Build(); | |
var settings = new MySettings(); | |
configuration.Bind(settings); | |
var moduleSettings = new MyModuleSettings(); | |
configuration.GetSection("SectionA").Bind(moduleSettings); | |
Console.WriteLine($"My application name is '{settings.ApplicationName}'"); | |
Console.WriteLine($"My module name is '{moduleSettings.ModuleName}'"); | |
Console.ReadLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment