This project has moved and is read-only. For the latest updates, please go here.

Filtering catalog on metadata

Jan 12, 2010 at 9:28 PM


I'm trying to filter all imports on a metadata attribute called "Version", using the FilteredCatalog class which can be found here: and with the following query:


(p => p.Metadata.ContainsKey("Version") && Convert.ToString(p.Metadata["Version"]) == "2.1")

The query always evaluates to false, even though there exist plugins which do have a metadata attribute called "Version" set to "2.1", and the following query also always evaluates to false:

(p => p.Metadata.ContainsKey("Version")) 

So it seems that the FilteredCatalog isn't finding the imported metadata. Here is how I declared the imported plugins:


private Lazy<IPlugin, IDictionary<string, object>>[] plugins { get; set; }

Why isn't the FilteredCatalog picking up the plugin metadata and how do I fix it?





Jan 12, 2010 at 9:55 PM

Hi Adam

The lambda above is filtering off of Part metadata NOT export metadata. MEF allows you do decorate parts with a [PartMetadata] attribute much like an export. To make your catalog above filter against exports, you need to apply the filter against the metadata of the part's ExportDefinitions.