Removing pending Configuration registration as Singleton.

Solving #9
This commit is contained in:
etomas 2017-02-07 09:35:21 +01:00
parent d07b98468b
commit 15f2cc7da1
3 changed files with 14 additions and 5 deletions

View File

@ -13,9 +13,9 @@
{
private string _connectionString = string.Empty;
public OrderQueries(IConfiguration configuration)
public OrderQueries(string constr)
{
_connectionString = configuration["ConnectionString"];
_connectionString = constr;
}

View File

@ -10,9 +10,19 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Autof
public class ApplicationModule
:Autofac.Module
{
public string QueriesConnectionString { get; }
public ApplicationModule(string qconstr)
{
QueriesConnectionString = qconstr;
}
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<OrderQueries>()
builder.Register(c => new OrderQueries(QueriesConnectionString))
.As<IOrderQueries>()
.InstancePerLifetimeScope();

View File

@ -82,7 +82,6 @@
// Add application services.
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddSingleton<IConfiguration>(this.Configuration);
services.AddTransient<IIdentityService,IdentityService>();
services.AddOptions();
@ -93,7 +92,7 @@
container.Populate(services);
container.RegisterModule(new MediatorModule());
container.RegisterModule(new ApplicationModule());
container.RegisterModule(new ApplicationModule(Configuration["ConnectionString"] ));
return new AutofacServiceProvider(container.Build());
}