I've been struggling to figure out the dependency pattern that comes with asp net core. Here is what I'm trying to achieve.
_ViewImports.cshtml
...
@inject AdminBuilder AdminBuilder
...
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
...
services.AddHttpContextIshSingleton<AdminBuilder>();
...
}
AnyCSHtmlFile.cshtml
@AdminBuilder.AddStuff()
@AdminBuilder.EnableStuff()
@AdminBuilder.DoStuff()
// It'll then populate the AdminBuilder instance, which needs to be a unique instance for each visit.
Layout.cshtml
Here I'll render the AdminBuilder at the bottom from a partial .cshtml file, based on what's been added while rendering the page.