提出问题提出问题
 

问题MEF and singletons

  • 2009年6月23日 9:47Gerhard 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    Hi,

    I have an object with more than one interface and I want to resolve this dependancies with MEF. But its important, that the instance of the object is a singleton, so how can I tell MEF to do so?

    Thanks

    Gerhard

全部回复

  • 2009年8月17日 10:04Craig Kuhnert 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    When you export your class use the creationpolicy attribute
    [PartCreationPolicy(CreationPolicy.Shared)]
    [Export(typeof(IMyInterface))]
    public class MyClass : IMyInterface
    {
    }