Castle Windsor Registration - AddAdditionalInterfaces() to implementation UsingFactoryMethod()
Given:
public class IFoo { }
public class IBar { }
public class FooImpl : IFoo { }
Why 开发者_如何学编程does this work:
container.Register(
Component.For<IFoo>()
.ImplementedBy<FooImpl>()
.Proxy.AddAdditionalInterfaces(typeof(IBar))
);
And this doesn't:
container.Register(
Component.For<IFoo>()
.UsingFactoryMethod(kernal => new FooImpl())
.Proxy.AddAdditionalInterfaces(typeof(IBar))
);
When after registration, we assert that:
container.Resolve<IFoo>().IsAssignableFrom(typeof(IBar)
It's just not supported (FactoryMethodActivator
doesn't support proxying at all). There's no good reason for that I guess, so feel free to request that feature.
精彩评论