Don't know if this is by design or not.
private interface IInterface
{
}
private class Decorator : IInterface
{
public Decorator(IInterface i)
{
}
}
private class Instance : IInterface
{
}
[Test]
public void When_Then_()
{
var container = new Container(x => x.For<IInterface>().Use<Instance>());
var i1 = container.GetInstance<IInterface>();
container.Configure(x => x.For<IInterface>().DecorateAllWith<Decorator>());
var i2 = container.GetInstance<IInterface>();
i2.Should().BeOfType<Decorator>();
}
Commenting out i1 instanciation works.
My feeling is DecorateAllWith should be applied when changing the runtime configuration even if a previous IInterface was instanciated without a decorator.
Workaround : Copy the x => x.For().Use() in the runtime configuration too.
Don't know if this is by design or not.
Commenting out i1 instanciation works.
My feeling is DecorateAllWith should be applied when changing the runtime configuration even if a previous IInterface was instanciated without a decorator.
Workaround : Copy the x => x.For().Use() in the runtime configuration too.