Issue #6894 invalid

CreateContainer, ConfigureContainer - inconsistency

Anonymous created an issue

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.

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.

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

Comments (1)

  1. Zach Davis staff

    It appears you're trying to file a bug against a project that is hosted on Bitbucket. This is the issue tracker for the Bitbucket website itself.

  2. Log in to comment