c# - How to import several instances with MEF? -


I have coded a service like this:

  public interface IMyInterface {.. .} [Export (Typef (IMI Interface)) Internal Square MySave: IMI Interface {...}  

Now, I import many instances of MyService I would like to have MEF in my main program.

How can I do this?

with [import] private IMyInterface MyService {get; Set; } I only get an example of MyService . In my main program, I would like to specify the number of imported frequency of MyService before dynamically the MEF structure.

I do not want to use [ImportMany] because I do not want to specify the number of exports in my MyService implementation.

Can you help me?

You probably do not want to import it directly, but many times the export value For this reason, you need to change the manufacturing policy for a non-shade, which forces the container to instantize a new instance every time.

Then get the price from the container:

  list & lt; IMyInterface & gt; Example = New list & lt; IMyInterface & gt; (); For (Int i = 0; I  

Comments