Unleash client instance as singleton
This commit is contained in:
@ -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> unleashClientSettings,
|
||||
IHostingEnvironment env,
|
||||
IUnleash unleashĈlient,
|
||||
ILogger<HomeController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_dbContext = dbContext;
|
||||
_unleashĈlient = env.CreateUnleahClient(unleashClientSettings.Value);
|
||||
_unleashĈlient = unleashĈlient;
|
||||
// _unleashĈlient = env.CreateUnleahClient(unleashClientSettings.Value);
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
|
@ -42,8 +42,7 @@ namespace isn.Controllers
|
||||
ILoggerFactory loggerFactory,
|
||||
IDataProtectionProvider provider,
|
||||
IOptions<NugetSettings> nugetOptions,
|
||||
IOptions<UnleashClientSettings> unleashClientSettings,
|
||||
IHostingEnvironment env,
|
||||
IUnleash unleashĈlient,
|
||||
ApplicationDbContext dbContext)
|
||||
{
|
||||
logger = loggerFactory.CreateLogger<PackagesController>();
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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<IAuthorizationHandler, ValidApiKeyRequirementHandler>();
|
||||
|
||||
services.AddSingleton<IUnleash>(s =>
|
||||
{
|
||||
var config = s.GetRequiredService<IOptions<UnleashClientSettings>>();
|
||||
return s.GetRequiredService<Microsoft.AspNetCore.Hosting.IHostingEnvironment>().CreateUnleahClient(config.Value);
|
||||
});
|
||||
|
||||
// _unleashĈlient = env.CreateUnleahClient(unleashClientSettings.Value);
|
||||
var smtpSettingsconf = Configuration.GetSection("Smtp");
|
||||
services.Configure<SmtpSettings>(smtpSettingsconf);
|
||||
var nugetSettingsconf = Configuration.GetSection("Nuget");
|
||||
|
Reference in New Issue
Block a user