Inject service without constructor

Friday, December 27, 2024 8:12:27 PM
  • Posted: Wednesday, July 21, 2021 1:49 PM
  • 17
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
  • 17
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