This situation reminds me of the way IClassifierProvider
is registered in the Visual Studio SDK. While many classifier providers may be exported throughout Visual Studio and its many extensions, in general very few (perhaps only one) apply to any single document you open for editing. To associate particular IClassifierProvider
exports with a limited number of documents, a metadata attribute is applied to the export, e.g. like the following:
[Export(typeof(IClassifierProvider))]
[ContentType("My Content Type")]
public class MyClassifierProvider : IClassifierProvider
Metadata attributes are efficient and well-supported inside MEF. In your application, you can expose them to users in one of the following ways:
Use the standard
ExportMetadataAttribute
attribute. Had Visual Studio done this, it might look like the following.[Export(typeof(IClassifierProvider))] [ExportMetadata("Content Type", "My Content Type")] public class MyClassifierProvider : IClassifierProvider
Create custom attributes that reflect the specific metadata you expect your extensions to provide.