title: MEF ImportingConstructor ImportMany with Metadata
body: <p>I'm using MEF to import many (with metadata) in a constructor. I've followed a video tutorial to try to mimic it but so far it's not quite working. Briefly, I have re-named some things and summarized, but:</p>
  
  <p>AbstractImportMe.cs</p>
  
  <pre><code>[InheritedExport(typeof(AbstractImportMe))]
  public abstract class AbstractImportMe{
  
  }
  </code></pre>
  
  <p>ImportMe.cs</p>
  
  <pre><code>[SimpleMetadata("Name")]
  class ImportMe : AbstractImportMe
  {
  
  }
  </code></pre>
  
  <p>SimpleMetadata.cs</p>
  
  <pre><code>[MetadataAttribute]
  public class SimpleMetadata : Attribute,ISimpleMetadata
  {
      public string Name { get; private set; }
      public SimpleMetadata(String Name)
      {
          this.Name = Name;
      }
  }
  </code></pre>
  
  <p>ISimpleMetadata.cs</p>
  
  <pre><code>public interface ISimpleMetadata
  {
      string Name { get; }
  }
  </code></pre>
  
  <p>Catalog.cs</p>
  
  <pre><code>[Export]
  public class Catalog
  {
  
      public IEnumerable&lt;Lazy&lt;AbstractImportMe, ISimpleMetadata&gt;&gt; imports = null;
  
      [ImportingConstructor]
      /*this runs but the imports field has 0 parts*/
      public Catalog([ImportMany] IEnumerable&lt;Lazy&lt;AbstractImportMe, ISimpleMetadata&gt;&gt; imports)
      {
          this.imports = imports;
      }
  
      /* this code works, but it lacks metadata
      public IEnumerable&lt;AbstractImportMe&gt; imports= null;
  
      [ImportingConstructor]
      public Catalog([ImportMany] IEnumerable&lt;AbstractImportMe&gt; imports)
      {
          this.imports = imports;
      }
      */
  }
  </code></pre>
  
  <p>Then I call this code:</p>
  
  <pre><code>AggregateCatalog catalog = new AggregateCatalog(newAssemblyCatalog(Assembly.GetEntryAssembly().Location));
  CompositionContainer container = new CompositionContainer(catalog);
  Catalog catalog = container.GetExportedValue&lt;Catalog&gt;();
  </code></pre>
  
  <p>The code runs, but I don't get any catalog.imports. When I look at the catalog there's 1 Catalog exported and an AbsractImportMe.</p>
  
  <p>As pointed out before, when I exclude the metadata from the import it works fine. So I think I have made a mistake somewhere in regards to the metadata.</p>