Wednesday, April 14, 2010

Hiding Parts From InheritedExport

In a previous post in my ongoing series on the Managed Extensibility Framework (MEF) I discussed using the InheritedExportAttribute in order to simply export declarations throughout a class hierarchy.  This attribute can be applied to either an Interface or a base class.  However, what if you wanted to implement the interface or inherit from the decorated base class (either directly or indirectly) but didn't want this new derived class to be imported during composition?  Thankfully, the designers of MEF thought of this issue and created the PartNotDiscoverableAttribute.  This attribute is very straightforward; simply place it on the part you wish to exclude and MEF will ignore it.

Post Links

No comments:

Post a Comment