I have in .net 5 a Configure method which is called by runtime
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IEventBusSubscriber bus){}
In the migration guide it is shown an example how to call it
var app = builder.Build();
startup.Configure(app, app.Environment);
I can pass to this method an app and env because I have an app instance, but what to do with IEventBusSubscriber?
Perhaps I could use app.Services.GetService(typeof(IEventBusSubscriber)) as IEventBusSubscriber
but it gives me possible null reference which I can avoid, but is it the right way to do it?