How to define the order with ImportMany attribute?

Posted by JD on Stack Overflow See other posts from Stack Overflow or by JD
Published on 2010-06-07T15:09:56Z Indexed on 2010/06/07 15:12 UTC
Read the original article Hit count: 303

Filed under:
|

Hi to all,

I am just getting into MEF and was wondering how you could define the order of collection exported with [ImportMany]?

What I mean here is if I had two classes (Class1, Class2) that implement the interface IService and each of the implementations are in two different libraries (although they could be in the same), I want the Class2 instance to be created before the Class1 instance in the IEnumerable collection defined by the ImportMany attribute. So it is like a pipeline of functionality where Class2 calls are made before Class1 calls.

Also, I have an another Class (Class3 which also implements IService) in another library, which I want introduced later on (i.e. some logging utility), how do I make this the 3rd instance in the ImportMany collection?

JD

© Stack Overflow or respective owner

Related posts about .NET

Related posts about MEF