Why not just have your module take an InstanceScope as a parameter
that way you can specify externally when creating the module which
InstanceScope you want the module to use.
> *public ContainerBuilder()*
> {
> this._registrars = new List<IModule>();
> this._defaultInstanceOwnership = InstanceOwnership.Container;
> * ** // this._defaultInstanceScope is implicitly assigned
> to InstanceScope.Singleton*
>
> }
>
> public virtual void RegisterModule(IModule module)
> {
> Enforce.ArgumentNotNull<IModule>(module, "module");
> this._registrars.Add(module);
>
> }
>
> public virtual IContainer Build()
> {
> Container container = new Container();
> this.Build(container);
> return container;
>
> }
>
> public virtual void Build(*IContainer container*)
> {
> Enforce.ArgumentNotNull<IContainer>(container, "container");
> if (this._wasBuilt)
> {
> throw new InvalidOperationException();
> }
> this._wasBuilt = true;
> foreach (IModule registrar in this._registrars)
> {
> *registrar.Configure(container);*
> }
>
> }
> }
>
> public abstract class Module : IModule
> {
> public virtual void Configure(IContainer container)
> {
> Enforce.ArgumentNotNull<IContainer>(container, "container");
> *ContainerBuilder builder = new ContainerBuilder();*
> *this.Load(builder);*