In my ConfigureServices, I have a number of dependencies configured. The following is repeated many times for different services so only the name of the service and interface name change along with values of some properties.
services.AddSingleton<IServiceName>(
client =>
{
return new ServiceName(new ServiceInfo
{
Url = "http://url"
});
});
As this is repeated many times and the URL changes for each service I am wondering if there is some way of doing this in a JSON file.
Hard coding the values means that we have to do a different build for production and using values from app settings for URL would mean creating a setting for each service and calling something like ServiceName.URL which would still be repetition.
Appreciate any ideas on how to achieve a simple solution that would all say 50+ services to be configurable without recompiling the app.