Castle Windsor注册 - AddAdditionalInterfaces()实现UsingFactoryMethod()

时间:2011-07-29 04:06:56

标签: castle-windsor castle

假设:

public class IFoo { }

public class IBar { }

public class FooImpl : IFoo { }

为什么这样做:

container.Register(
    Component.For<IFoo>()
             .ImplementedBy<FooImpl>()
             .Proxy.AddAdditionalInterfaces(typeof(IBar))
);

这不是:

container.Register(
    Component.For<IFoo>()
             .UsingFactoryMethod(kernal => new FooImpl())
             .Proxy.AddAdditionalInterfaces(typeof(IBar))
);

注册后,我们断言:

container.Resolve<IFoo>().IsAssignableFrom(typeof(IBar)

1 个答案:

答案 0 :(得分:0)

它不受支持(FactoryMethodActivator根本不支持代理)。我猜这是没有充分理由的,所以请随意request that feature.

相关问题