File tree Expand file tree Collapse file tree
src/Services/Ordering/Ordering.API
Infrastructure/AutofacModules Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,9 +13,9 @@ public class OrderQueries
1313 {
1414 private string _connectionString = string . Empty ;
1515
16- public OrderQueries ( IConfiguration configuration )
16+ public OrderQueries ( string constr )
1717 {
18- _connectionString = configuration [ "ConnectionString" ] ;
18+ _connectionString = constr ;
1919 }
2020
2121
Original file line number Diff line number Diff line change @@ -10,9 +10,19 @@ namespace Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure.Autof
1010 public class ApplicationModule
1111 : Autofac . Module
1212 {
13+
14+ public string QueriesConnectionString { get ; }
15+
16+ public ApplicationModule ( string qconstr )
17+ {
18+ QueriesConnectionString = qconstr ;
19+
20+ }
21+
1322 protected override void Load ( ContainerBuilder builder )
1423 {
15- builder . RegisterType < OrderQueries > ( )
24+
25+ builder . Register ( c => new OrderQueries ( QueriesConnectionString ) )
1626 . As < IOrderQueries > ( )
1727 . InstancePerLifetimeScope ( ) ;
1828
Original file line number Diff line number Diff line change @@ -82,7 +82,6 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
8282
8383 // Add application services.
8484 services . AddSingleton < IHttpContextAccessor , HttpContextAccessor > ( ) ;
85- services . AddSingleton < IConfiguration > ( this . Configuration ) ;
8685 services . AddTransient < IIdentityService , IdentityService > ( ) ;
8786
8887 services . AddOptions ( ) ;
@@ -93,7 +92,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
9392 container . Populate ( services ) ;
9493
9594 container . RegisterModule ( new MediatorModule ( ) ) ;
96- container . RegisterModule ( new ApplicationModule ( ) ) ;
95+ container . RegisterModule ( new ApplicationModule ( Configuration [ "ConnectionString" ] ) ) ;
9796
9897 return new AutofacServiceProvider ( container . Build ( ) ) ;
9998 }
You can’t perform that action at this time.
0 commit comments