To add configuration to your .NET Core application, you can use the ConfigurationBuilder class and read the values from the appsettings.json file.
Here's an example of how to do this:
Create a new instance of ConfigurationBuilder:
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
Build the configuration object:
IConfigurationRoot configuration = builder.Build();
Use the GetValue method to read the configuration value:
var value = configuration.GetValue<string>("YourConfigKey");
So, for example, if you have a setting called WrapperApiKey, your appsettings.json file could look like this:
{
"WrapperApiKey": "your_api_key_here"
}
And you could read the value in your code like this:
var apiKey = configuration.GetValue<string>("WrapperApiKey");
Make sure to replace "YourConfigKey" with the actual key you want to read from the appsettings.json file.