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
最佳答案
ObjectFactory.Initialize(x =>
{
x.For<IInterface1>().Singleton().Use<MyClass>();
x.Forward<IInterface1, IInterface2>();
});
关于.net - StructureMap:如何为其所有接口(interface)注册相同的实例,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2535178/