StructureMap singleton usage (A class implementing two interface)

后端 未结 4 430
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-01 04:46
public interface IInterface1
{
}

public interface IInterface2
{
}

public class MyClass : IInterface1, IInterface2
{
}

...

ObjectFactory.Initialize(x =>
{
             


        
4条回答
  •  不知归路
    2020-12-01 05:05

    You can use the Forward<,>() registration to tell StructureMap to resolve a type using the resolution of a different type. This should do what you expect:

    ObjectFactory.Initialize(x =>
    {
        x.For().Singleton().Use();
        x.Forward();
    });
    

提交回复
热议问题