發問發問
 

問題MEF and singletons

  • 2009年6月23日 上午 09: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
    • 已移動Mathias SchifferMSFT2009年6月23日 上午 10:28English Language Post (From:.NET Framework)
    •  

所有回覆

  • 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
    {
    }