--
You received this message because you are subscribed to the Google Groups "Autofac" group.
To post to this group, send email to aut...@googlegroups.com.
To unsubscribe from this group, send email to autofac+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/autofac?hl=en.
For example, we wanted all of our registrations to be container scoped
by default, so we set this option as soon as we create the
ContainerBuilder instance. When we then proceed to load modules the
default for each module reverts to the system default (which is
singleton in the version we are running). This seemed to be against my
intuition but may make sense?
I expected the test below to pass... but it fails. Any thoughts on how
this should be handled?
[Test]
public void ContainerBuilderDefaultAppliesToLoadedModules()
{
var cb = new ContainerBuilder();
cb.SetDefaultScope(InstanceScope.Container);
cb.RegisterModule(new DummyModule());
var container = cb.Build();
var outerDummy = container.Resolve<IDummy>();
IDummy innerDummy;
using (var inner = container.CreateInnerContainer())
{
innerDummy = inner.Resolve<IDummy>();
}
//should not be the same because I expected the default
scope to be applied to the module
Assert.AreNotSame(outerDummy, innerDummy);
}
internal class DummyModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.Register<Dummy>().As<IDummy>();
}
}
}
}