lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [lucenenet] NightOwl888 commented on issue #323: Method 'get_Providers' in type 'Lucene.Net.Configuration.ConfigurationRoot' does not have an implementation.
Date Mon, 03 Aug 2020 19:47:20 GMT

NightOwl888 commented on issue #323:

   Thanks for the report.
   What packages do you have from `Microsoft.Extensions.Configuration` installed in your project?
And what versions?
   I was able to reproduce this. I still need to look into why this is happening. The `Providers`
property hasn't changed from `IEnumerable<IConfigurationProvider>`, so it is a bit odd
that it is throwing an exception.
   Fortunately, this time there is a workaround. You can bypass the `ConfigurationRoot` provider
by injecting your own at application startup. Just provide your existing `IConfiguration`
instance to `ConfigurationFactory`, or use the below code as the default.
   IConfiguration configuration = new ConfigurationBuilder().AddEnvironmentVariables("lucene:").Build();
   Lucene.Net.Configuration.ConfigurationSettings.SetConfigurationFactory(new ConfigurationFactory(configuration));
   Here is one way to implement `ConfigurationFactory`. You could alternatively use a `Func<IConfiguration>`
in the constructor and actively read it on the fly from its source if you need to.
       public class ConfigurationFactory : Lucene.Net.Configuration.IConfigurationFactory
           private readonly IConfiguration configuration;
           public ConfigurationFactory(IConfiguration configuration)
               this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
           public IConfiguration GetConfiguration() => configuration;

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:

View raw message