开发者

Castle Windsor Registration - AddAdditionalInterfaces() to implementation UsingFactoryMethod()

开发者 https://www.devze.com 2023-03-24 05:22 出处:网络
Given: public class IFoo { } public class IBar { } public class FooImpl : IFoo { } Why 开发者_如何学编程does this work:

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

精彩评论

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

关注公众号