StructureMap新手问题。
public class SomeClass: IInterface1, IInterface2 {
}
我希望通过以下测试:
Assert.AreSameInstance(
container.GetInstance<IInterface1>(),
container.GetInstance<IInterface2>());
我如何明确注册?
我知道在温莎城堡我会做类似
的事情kernel.Register(Component.For(typeof(IInterface1), typeof(IInterface2))
.ImplementedBy(typeof(SomeClass));
但我没有看到任何等效的API
答案 0 :(得分:15)
ObjectFactory.Initialize(x =>
{
x.For<IInterface1>().Singleton().Use<MyClass>();
x.Forward<IInterface1, IInterface2>();
});