StructureMap新手的问题。
公共类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()使用<。&MyClass的GT;();
x.Forward&所述; IInterface1,IInterface2>();
});
StructureMap newbie question.
public class SomeClass: IInterface1, IInterface2 {
}
I would like the following test to pass:
Assert.AreSameInstance(
container.GetInstance<IInterface1>(),
container.GetInstance<IInterface2>());
How would I do an explicit registration of this?
I know in Castle Windsor I would do something like
kernel.Register(Component.For(typeof(IInterface1), typeof(IInterface2))
.ImplementedBy(typeof(SomeClass));
But I don't see any equivalent API
解决方案ObjectFactory.Initialize(x =>
{
x.For<IInterface1>().Singleton().Use<MyClass>();
x.Forward<IInterface1, IInterface2>();
});