Trying to create a IConfigurationRoot type object to consume Core 2.2 Api from legacy dotnet framework 4.7.1 WPF app config file.
myCoreApiController.CoreApiMethod( confirutation); // (IConfigurationRoot configuration)
First defined a Dictionary and load it with keys that identify your configuration settings and values (the actual settings). That code looks like this:
var settings = new Dictionary<string, string>
{
{"toDoService:url", "http://..."},
{"toDoService:contractid", "???"}
};
Then created a ConfigurationBuilder, add my Dictionary of configuration settings to it and use that ConfigurationBuilder to build an IConfiguration object.
Here's that code:
var cfgBuilder = new ConfigurationBuilder();
cfgBuilder.AddInMemoryCollection(settings);
IConfiguration cfg = cfgBuilder.Build();
But the ConfigurationBuilder is also an Interface. So I can't create instance of that.
Then I tried to implement that and create my own but could not over override AddInMemoryCollection static method.
So the upper solution is not working.
Please note that the project has the NuGet Microsoft.Extensions.Configuration, Microsoft.Extensions.Configuration.Abstractions are installed.
Hope, some one will share their way to achieve that.
I just encountered this 'issue'. My problem was that I had:
but what I need is: