开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜