diff --git a/src/isnd/Controllers/HomeController.cs b/src/isnd/Controllers/HomeController.cs index 3f84696..6e37e7c 100644 --- a/src/isnd/Controllers/HomeController.cs +++ b/src/isnd/Controllers/HomeController.cs @@ -19,17 +19,18 @@ namespace isn.Controllers { private readonly ILogger _logger; private readonly ApplicationDbContext _dbContext; + private readonly IHostingEnvironment _env; private readonly IUnleash _unleashĈlient; public HomeController( ApplicationDbContext dbContext, - IOptions unleashClientSettings, - IHostingEnvironment env, + IUnleash unleashĈlient, ILogger logger) { _logger = logger; _dbContext = dbContext; - _unleashĈlient = env.CreateUnleahClient(unleashClientSettings.Value); + _unleashĈlient = unleashĈlient; + // _unleashĈlient = env.CreateUnleahClient(unleashClientSettings.Value); } public IActionResult Index() diff --git a/src/isnd/Controllers/PackagesController.cs b/src/isnd/Controllers/PackagesController.cs index 8e19b0f..5b0e0ea 100644 --- a/src/isnd/Controllers/PackagesController.cs +++ b/src/isnd/Controllers/PackagesController.cs @@ -42,8 +42,7 @@ namespace isn.Controllers ILoggerFactory loggerFactory, IDataProtectionProvider provider, IOptions nugetOptions, - IOptions unleashClientSettings, - IHostingEnvironment env, + IUnleash unleashĈlient, ApplicationDbContext dbContext) { logger = loggerFactory.CreateLogger(); @@ -51,7 +50,7 @@ namespace isn.Controllers protector = provider.CreateProtector(nugetSettings.ProtectionTitle); this.dbContext = dbContext; this.packageManager = packageManager; - _unleashĈlient = env.CreateUnleahClient(unleashClientSettings.Value); + _unleashĈlient = unleashĈlient; ressources = packageManager.GetResources(_unleashĈlient).ToArray(); } diff --git a/src/isnd/Startup.cs b/src/isnd/Startup.cs index 1a23bc6..ead6c85 100644 --- a/src/isnd/Startup.cs +++ b/src/isnd/Startup.cs @@ -19,6 +19,7 @@ using System; using Unleash.ClientFactory; using isnd.Entities; using Microsoft.Extensions.Options; +using isnd.Helpers; namespace isn { @@ -64,7 +65,13 @@ namespace isn }); services.AddSingleton(); - + services.AddSingleton(s => + { + var config = s.GetRequiredService>(); + return s.GetRequiredService().CreateUnleahClient(config.Value); + }); + + // _unleashĈlient = env.CreateUnleahClient(unleashClientSettings.Value); var smtpSettingsconf = Configuration.GetSection("Smtp"); services.Configure(smtpSettingsconf); var nugetSettingsconf = Configuration.GetSection("Nuget");