title: MEF : Discover plugin using ExportMetaData attribute
body: <p>In the below code I discover all the plugins using the contract ICalculator and then pick the plugin depending on the metat data attribute.</p>
  
  <p>I need to discover the plugin depending on the ExportMetadata attribute  directly and not on the Interface contract type "ICalculator".
  Is there any way I can do that?</p>
  
  <p>Thanks!</p>
  
  <pre class="lang-cs prettyprint-override"><code>public abstract class MathOperation : ICalculator
  {
      public abstract int GetNumber(int num1, int num2);      
  }
  
  [Export(typeof(ICalculator))]
  [ExportMetadata("CalciMetaData", "Add")]
  public class Add : MathOperation
  {
      #region Interface members
      public override int GetNumber(int num1, int num2)
      {
          return num1 + num2;
      }
      #endregion
  }
  
  [Export(typeof(ICalculator))]
  [ExportMetadata("CalciMetaData", "Divide")]
  public class Divide : MathOperation
  {
      #region Interface members
      public override int GetNumber(int num1, int num2)
      {
          return num1 / num2;
      }
      #endregion
  }
  
  // Composition.
  public class CalciCompositionHelper
  {
      [ImportMany]
      public System.Lazy&lt;ICalculator, IDictionary&lt;string, object&gt;&gt;[] CalciPlugins { get; set; }
  
      /// &lt;summary&gt;
      /// Assembles the calculator components
      /// &lt;/summary&gt;
      public void AssembleCalculatorComponents()
      {
          try
          {
              //Step 1: Initializes a new instance of the 
              //        System.ComponentModel.Composition.Hosting.AssemblyCatalog class with the 
              //        current executing assembly.
              var catalog = new AssemblyCatalog(Assembly.LoadFrom(@"D:\Study\MEF_Program_Files\Files\SimpleCalculator-Part2\CalculatorUI\CalculatorFactory\bin\Debug\CalculatorFactory.dll"));
  
              //Step 2: The assemblies obtained in step 1 are added to the CompositionContainer
              var container = new CompositionContainer(catalog);
  
              //Step 3: Composable parts are created here i.e. the Import and Export components 
              //        assembles here
              container.ComposeParts(this);
          }
          catch (Exception ex)
          {
              throw ex;
          }
      }
  
      /// &lt;summary&gt;
      /// Sends the result back to the client
      /// &lt;/summary&gt;
      /// &lt;param name="num1"&gt;&lt;/param&gt;
      /// &lt;param name="num2"&gt;&lt;/param&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      public int GetResult(int num1, int num2, string operationType)
      {
          int result = 0;
          foreach (var CalciPlugin in CalciPlugins)
          {
              if ((string)CalciPlugin.Metadata["CalciMetaData"] == operationType)
              {
                  result = CalciPlugin.Value.GetNumber(num1, num2);
                  break;
              }                               
          }
          return result;           
      }
  }
  </code></pre>