Formula una domandaFormula una domanda
 

DomandaMEF and singletons

  • martedì 23 giugno 2009 9.47Gerhard Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    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
    • SpostatoMathias SchifferMSFTmartedì 23 giugno 2009 10.28English Language Post (From:.NET Framework)
    •  

Tutte le risposte

  • lunedì 17 agosto 2009 10.04Craig Kuhnert Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     
    When you export your class use the creationpolicy attribute
    [PartCreationPolicy(CreationPolicy.Shared)]
    [Export(typeof(IMyInterface))]
    public class MyClass : IMyInterface
    {
    }