Inject service without constructor

Wednesday, July 28, 2021 12:44:55 PM
  • Posted: Wednesday, July 21, 2021 1:49 PM
  • 10
Hi guys,
I work on my plugin. I need to get myPlugginSettings in "EndpointProvider.cs" but I cannt inject the setting with constructor. Is there any solution?

My code not work:
private readonly MSNFeaturesSettings _msnFeaturesSettings;

        public EndpointProvider(MSNFeaturesSettings msnFeaturesSettings)
        {
            _msnFeaturesSettings = msnFeaturesSettings;
        }
0
  • Posted: Wednesday, July 21, 2021 4:43 PM
  • 10
I found a solution:

            var connection = DataSettingsManager.LoadSettings();

            var gSettings = new MongoRepository<Setting>(connection.ConnectionString).Table.Where(x => x.Name.StartsWith("msnfeaturessettings"));
            if (gSettings.Any())
            {
                var metadata = gSettings.FirstOrDefault().Metadata;
                _msnFeaturesSettings = JsonSerializer.Deserialize<MSNFeaturesSettings>(metadata);
            }
0
back to top
Filters