Unleash client instance as singleton
This commit is contained in:
parent
a345992351
commit
cd7c0be03d
3 changed files with 14 additions and 7 deletions
|
|
@ -19,17 +19,18 @@ namespace isn.Controllers
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ApplicationDbContext _dbContext;
|
private readonly ApplicationDbContext _dbContext;
|
||||||
|
private readonly IHostingEnvironment _env;
|
||||||
private readonly IUnleash _unleashĈlient;
|
private readonly IUnleash _unleashĈlient;
|
||||||
|
|
||||||
public HomeController(
|
public HomeController(
|
||||||
ApplicationDbContext dbContext,
|
ApplicationDbContext dbContext,
|
||||||
IOptions<UnleashClientSettings> unleashClientSettings,
|
IUnleash unleashĈlient,
|
||||||
IHostingEnvironment env,
|
|
||||||
ILogger<HomeController> logger)
|
ILogger<HomeController> logger)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
_unleashĈlient = env.CreateUnleahClient(unleashClientSettings.Value);
|
_unleashĈlient = unleashĈlient;
|
||||||
|
// _unleashĈlient = env.CreateUnleahClient(unleashClientSettings.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,7 @@ namespace isn.Controllers
|
||||||
ILoggerFactory loggerFactory,
|
ILoggerFactory loggerFactory,
|
||||||
IDataProtectionProvider provider,
|
IDataProtectionProvider provider,
|
||||||
IOptions<NugetSettings> nugetOptions,
|
IOptions<NugetSettings> nugetOptions,
|
||||||
IOptions<UnleashClientSettings> unleashClientSettings,
|
IUnleash unleashĈlient,
|
||||||
IHostingEnvironment env,
|
|
||||||
ApplicationDbContext dbContext)
|
ApplicationDbContext dbContext)
|
||||||
{
|
{
|
||||||
logger = loggerFactory.CreateLogger<PackagesController>();
|
logger = loggerFactory.CreateLogger<PackagesController>();
|
||||||
|
|
@ -51,7 +50,7 @@ namespace isn.Controllers
|
||||||
protector = provider.CreateProtector(nugetSettings.ProtectionTitle);
|
protector = provider.CreateProtector(nugetSettings.ProtectionTitle);
|
||||||
this.dbContext = dbContext;
|
this.dbContext = dbContext;
|
||||||
this.packageManager = packageManager;
|
this.packageManager = packageManager;
|
||||||
_unleashĈlient = env.CreateUnleahClient(unleashClientSettings.Value);
|
_unleashĈlient = unleashĈlient;
|
||||||
ressources = packageManager.GetResources(_unleashĈlient).ToArray();
|
ressources = packageManager.GetResources(_unleashĈlient).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ using System;
|
||||||
using Unleash.ClientFactory;
|
using Unleash.ClientFactory;
|
||||||
using isnd.Entities;
|
using isnd.Entities;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using isnd.Helpers;
|
||||||
|
|
||||||
namespace isn
|
namespace isn
|
||||||
{
|
{
|
||||||
|
|
@ -64,7 +65,13 @@ namespace isn
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddSingleton<IAuthorizationHandler, ValidApiKeyRequirementHandler>();
|
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");
|
var smtpSettingsconf = Configuration.GetSection("Smtp");
|
||||||
services.Configure<SmtpSettings>(smtpSettingsconf);
|
services.Configure<SmtpSettings>(smtpSettingsconf);
|
||||||
var nugetSettingsconf = Configuration.GetSection("Nuget");
|
var nugetSettingsconf = Configuration.GetSection("Nuget");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue