Allow SmartInspect configuration via JSON file and IConfiguration
To be able to use the .NET Core approach using IConfiguration, the SmartInspect settings might be moved to a JSON file into its own section.
Especially the ability to override the file settings by user secrets is useful.
It makes developers independent from each other and it is easier to handle the JSON file by source control system.
Code may look like this:
IConfiguration configuration = new ConfigurationBuilder()
.AddJsonFile(@".appsettings.json", optional: false, reloadOnChange: true) // Option 1 – own section within appsettings.json
.AddJsonFile(@".smartinspect.json", optional: false, reloadOnChange: true) // Option 2 – own JSON file
.AddEnvironmentVariables()
.AddCommandLine(Environment.GetCommandLineArgs())
.AddUserSecrets(typeof(App).Assembly) // Override previous settings by individual values
.Build();
SiAuto.Si.Connections = SmartInspectConnectionFactory.LoadFrom(configuration);
One thought on “Allow SmartInspect configuration via JSON file and IConfiguration”
Leave a Reply
You must be logged in to post a comment.

To keep your current namings the call could also be
SiAuto.Si.LoadConfiguration(configuration);