.NET Framework Bookmark and Share   
 index > Managed Extensibility Framework > How to import all implementations of specified interface.
 

How to import all implementations of specified interface.

Such as follows:
publicclassClass1
{
[Import]
publicIEnumerable<ISpecifiedInterface>AllObjects{get;set;}.
}

ColinHan
Just for your information, if you replace the colleciton type to IList<T>, it will also work, but you do not have the benefits of delay loading.

We had a second preview of MEF at CodePlex(http://www.codeplex.com/MEF)and it is open source. You may like to try outa newer version of MEFand post your questions there.

Thanks,
Zhenlan
  • Marked As Answer byColinHan Tuesday, October 21, 2008 2:07 AM
  •  
Zhenlan Wang
Aha, I found the solution of this function. I need write the code as follows:

publicclassClass1
{
[Import]
publicImportInfoCollection<ISpecifiedInterface>AllObjects{get;set;}.
}

  • Marked As Answer byColinHan Friday, October 17, 2008 9:22 AM
  •  
ColinHan
Aha, I found the solution of this function. I need write the code as follows:

publicclassClass1
{
[Import]
publicImportInfoCollection<ISpecifiedInterface>AllObjects{get;set;}.
}

  • Marked As Answer byColinHan Friday, October 17, 2008 9:22 AM
  •  
ColinHan
Just for your information, if you replace the colleciton type to IList<T>, it will also work, but you do not have the benefits of delay loading.

We had a second preview of MEF at CodePlex(http://www.codeplex.com/MEF)and it is open source. You may like to try outa newer version of MEFand post your questions there.

Thanks,
Zhenlan
  • Marked As Answer byColinHan Tuesday, October 21, 2008 2:07 AM
  •  
Zhenlan Wang

What you have done should work - we'll automatically populatethe IEnumerable<T> instance.


Managed Extensibility Framework Team | My Blog: http://davesbox.com
David M. Kean

You can use google to search for other answers

Custom Search

More Threads

• Several contributors to unity configuration in app.config ?
• Registry access error in ApplicationBlocks.ExceptionManagement when using Custom Publisher
• editPoint.get_CodeElement(vsCMElement.vsCMElementEnum) returns null
• Do you support the Default export option
• Weird crash when Candidate provider does not export the imported type
• How to pass an Enum to a Functon
• pinvoke query
• Error accessing a C++/CLI wrapper method from C#
• One framework to rule them all?
• no microphone