Another question
Closed this issue ยท 2 comments
lonix1 commented
Hey again @henkmollema, I've been using your code for a while and it's really useful, thanks again! ๐
One more question about your implementation if you don't mind?
StartupModuleRunner
has this:
public void Configure(IApplicationBuilder app, IConfiguration configuration, IWebHostEnvironment hostingEnvironment)
{
using var scope = app.ApplicationServices.CreateScope(); // <----------- ???
var ctx = new ConfigureMiddlewareContext(configuration, hostingEnvironment, scope.ServiceProvider, _options);
foreach (var cfg in _options.StartupModules)
{
cfg.Configure(app, ctx);
}
}
You create a scope and use it to create a scoped container. That becomes available in a StartupModule's Configure()
method.
Why?
This is the signature:
void Configure(IApplicationBuilder app, ConfigureMiddlewareContext context);
As you can see you could use app.ApplicationServices
instead.
Can we simplify this code, or is there a reason for it I don't understand?
lonix1 commented
I think I discovered the answer here. Thanks.
henkmollema commented
That's exactly the reason indeed.
Op do 1 jul. 2021 12:01 schreef lonix1 ***@***.***>:
โฆ Closed #15 <#15>.
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#15 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALTMN6ERG2IAQCJITCV4ATTVQ4GJANCNFSM47T3GSSQ>
.