Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>MEF preview 8 has experimental support for this, though it is not yet included in <code>System.ComponentModel.Composition.dll</code>. See <a href="http://blogs.msdn.com/nblumhardt/archive/2009/08/28/dynamic-part-instantiation-in-mef.aspx" rel="nofollow noreferrer">this blog post</a> for more information.</p> <p>You'll have to download the MEF sources and build the solution. In the <code>Samples\DynamicInstantiation</code> folder you'll find the assembly <code>Microsoft.ComponentModel.Composition.DynamicInstantiation.dll</code>. Add a reference to this assembly and add a dynamic instantiation provider to your container like this:</p> <pre><code>var catalog = new DirectoryCatalog("."); var dynamicInstantiationProvider = new DynamicInstantiationProvider(); var container = new CompositionContainer(catalog, dynamicInstantiationProvider); dynamicInstantiationProvider.SourceProvider = container; </code></pre> <p>Now your parts will be able to import a <code>PartCreator&lt;Foo&gt;</code> if they need to dynamically create <code>Foo</code> parts. The advantage over writing your own factory class is that this will transparently take care of the imports of <code>Foo</code>, and the imports' imports, etcetera.</p> <p><strong>edit</strong>:</p> <ul> <li>in <a href="http://mef.codeplex.com/releases/view/40606" rel="nofollow noreferrer">MEF Preview 9</a> <code>PartCreator</code> was renamed to <code>ExportFactory</code> but it is only included in the silverlight edition.</li> <li>in <a href="http://mef.codeplex.com/releases/view/53792" rel="nofollow noreferrer">MEF 2 Preview 2</a>, <code>ExportFactory</code> became included for the desktop edition. So <code>ExportFactory</code> will probably be part of the next .NET framework version after .NET 4.0.</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload