StructureMap: How to register the same instance for all its interfaces

Posted by George Mauer on Stack Overflow See other posts from Stack Overflow or by George Mauer
Published on 2010-03-29T00:27:22Z Indexed on 2010/03/29 0:33 UTC
Read the original article Hit count: 378

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about ioc

Related posts about .NET