none
Class instances creation using MEF RRS feed

  • Question

  • Hi,

    I have class implementing one interface e.g.

    interface IFoo

    {}

    Class Foo : IFoo

    {}

    Using ServiceLocator, I want to create multiple instances of class in following manner: -

    1. instance CommonFoo

    2. instance SpecificFoo1

    3. instance SpecificFoo2

    How to export this class in such a way that if I pass "Specific" as parameter to ServiceLocator it will create new instance every time. But if I pass "Common" as parameter, ServiceLocator will create only one instance

    Regards,

    Sharda

    Tuesday, April 21, 2015 9:14 AM

All replies

  • Hi Sharda,

    Per my understanding, you want to determine retrieving Singleton object programmatically. From the description of the following link, http://blogs.msdn.com/b/gblock/archive/2009/01/29/managed-extensibility-framework-preview-4-a-grab-bag-of-goodies.aspx, it is supported from MEF version 4. Please check it and try the solution on that blog. Feel free to let me know the result.

    Regards,    


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 22, 2015 3:49 AM
    Moderator
  • Hi Herro,

    I have gone through the link and understood that I have to export the class with PartCreationPolicy as Any.

    But how the customer classes will create class instance without using Import. Is there any other way?

    Regards,

    Sharda.

    Wednesday, April 22, 2015 6:00 AM
  • But how the customer classes will create class instance without using Import. Is there any other way?

    Can you share a repro project on your OneDrive and share a link here? I cannot say something useful without understanding what is the customer classes.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, April 30, 2015 2:37 AM