StructureMap singleton usage (A class implementing two interface)

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

public interface IInterface2
{
}

public class MyClass : IInterface1, IInterface2
{
}

...

ObjectFactory.Initialize(x =>
{
             


        
4条回答
  •  孤街浪徒
    2020-12-01 04:48

    An ObjectFactory is intended to create multiple instances. If you want a singleton, write a singleton class (perhaps with public IInterface1 and IInterface2 properties as accessors).

    It seems sketchily documented, but perhaps you can use a Container instead.

提交回复
热议问题