0
鑑於:城堡溫莎註冊 - AddAdditionalInterfaces()實施UsingFactoryMethod()
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)
我會這麼做的。謝謝。 –