Last active
March 24, 2021 16:47
-
-
Save bjornmicallef/4e82b1611a566e6a3990b29859ad68fd to your computer and use it in GitHub Desktop.
This file contains 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 static class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var cfg = InitOptions<AppConfig>(); | |
var setupDirectory = Path.Combine(cfg.SetupFilePath, cfg.SetupFileName); | |
var setupLines = File.ReadAllLines(setupDirectory); | |
var validation = new Validation(); | |
var result = validation.ValidateSetupFile(setupLines); | |
if (result == Result.ValidationOk) | |
// execute moves | |
Console.WriteLine(new Response(result).Description); | |
Console.ReadKey(); | |
} | |
private static T InitOptions<T>() where T : new() | |
{ | |
var config = InitConfig(); | |
return config.Get<T>(); | |
} | |
private static IConfigurationRoot InitConfig() | |
{ | |
// load setup file name and path from appsettings.json | |
var builder = new ConfigurationBuilder() | |
.AddJsonFile($"appsettings.json", true, true) | |
.AddEnvironmentVariables(); | |
return builder.Build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment