Replacement for ExportCollection?

Jul 14, 2009 at 1:10 AM

Hi

I am new to MEF and am trying to work through an example I found that was built with an older version of MEF.

How would I rewrite the following code to work with MEF 6?  I think ExportCollection is no longer supported.

[ImportMany]
        ExportCollection<IOperation, IOperationData> operations;

Coordinator
Jul 14, 2009 at 2:57 AM

Use IEnumerable or an array of Lazy<T, TMetadata>:

 

 

//  IEnumerable
[ImportMany]
IEnumerable<Lazy<IOperation, IOperationData>> Operations;

// Array
[ImportMany]
Lazy<IOperation, IOperationData>[] Operations;

See this blog post for more information about what's changed in preview 6: http://blogs.msdn.com/nblumhardt/archive/2009/07/09/mef-preview-6-available.aspx