Skip to main content
Fix indentation
Source Link
Petter Hesselberg
  • 5.6k
  • 3
  • 29
  • 51

You can inject dependencies using IApplicationBuilder instance in this way

public void Configure(IApplicationBuilder app)  {   //---------- Your code     using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())   {   var resultLogic = serviceScope.ServiceProvider.GetService<IResultLogic>();   resultLogic.YourMethod();   }    //---------- Your code  } 

You can inject dependencies using IApplicationBuilder instance in this way

public void Configure(IApplicationBuilder app)  {   //---------- Your code     using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())   {   var resultLogic = serviceScope.ServiceProvider.GetService<IResultLogic>();   resultLogic.YourMethod();   }    //---------- Your code  } 

You can inject dependencies using IApplicationBuilder instance in this way

public void Configure(IApplicationBuilder app) { //---------- Your code using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope()) { var resultLogic = serviceScope.ServiceProvider.GetService<IResultLogic>(); resultLogic.YourMethod(); } //---------- Your code } 
Source Link

You can inject dependencies using IApplicationBuilder instance in this way

public void Configure(IApplicationBuilder app) { //---------- Your code using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope()) { var resultLogic = serviceScope.ServiceProvider.GetService<IResultLogic>(); resultLogic.YourMethod(); } //---------- Your code }