Details
-
Suggestion
-
Resolution: Invalid
Description
Inother Bootstrappers (Mef, Unity), CreateContainer is called first, than ConfigureContainer,
this is the logical order of things developers used to.
AutofacBootstrapper is doing it the other way around, which is confusing at first and need to dig in AutofacBoostrapper source code to understand.
(Although it's logical for Autofac, as ContainerBuilder is created first)
In addition it's not simple at all to perform some logic after Container is created,
For example, if it's required to create Multitenant container during the Boorstrapper execution
ie.
#!C#
new MultitenantContainer(renantIdentificationStrategy, **base.Container**);
It cannot be done in ConfigureContainer (Which logically developers would assume is the place)
nor in CreateContainer, since the Base.Build is not available in derive Boostrapper
ie.
#!C# protected override IContainer CreateContainer() { var container = base.Builder.Build(); _multitenant = new MultitenantContainer(_tenantIdentificationStrategy, container); return }
currently only ugly workarounds work, like storing in a field the ContainerBuilder we got in ConfigureContainer and later in CreateContainer, use it to create the Container and the MultitenantContainer
It would be nice to simplify developers' experience for cases Container is required
thanks