Search code examples
c#mefioc-container

Resolving multiple instances in collection with MEF


Is it possible to fill a collection-type property with MEF-resolved entities? Just like

[Import(typeof(ClassA))]
[Import(typeof(ClassB))]
[Import(typeof(ClassC))]
public List<IA> ListOfIA { get; set; }

Here ClassA, ClassB, CalssC are all inheritants of IA and supplied by MEF Export attributes.


Solution

  • Well, it is helpful to read documentation before starting to use some framework. It can be simply achieved by using ImportMany MEF attribute