Add system level config override

This commit is contained in:
John Lewin 2018-09-04 12:18:11 -07:00
parent 5cf7f9a81f
commit 3ae9c19fb6

View file

@ -51,14 +51,18 @@ namespace MatterHackers.MatterControl
AggContext.Config.ProviderTypes.SystemWindow = "MatterHackers.Agg.UI.OpenGLSystemWindow, agg_platform_win32";
AggContext.Config.ProviderTypes.SystemWindowProvider = "MatterHackers.Agg.UI.WinformsSystemWindowProvider, agg_platform_win32";
string userProfilePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
// Load optional user configuration
IConfiguration config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true)
.AddJsonFile(Path.Combine(userProfilePath, "MatterControl.json"), optional: true)
.Build();
// Override defaults via configuration
config.Bind("Agg:ProviderTypes", AggContext.Config.ProviderTypes);
config.Bind("Agg:GraphicsMode", AggContext.Config.GraphicsMode);
Slicer.RunInProcess = config.GetValue<bool>("MatterControl:Slicer:Debug");
// Make sure we have the right working directory as we assume everything relative to the executable.