Inject service without constructor

Monday, November 25, 2024 4:38:23 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