using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ComponentModel.Composition; using System.ComponentModel.Composition.Hosting; namespace MefPlugin { class MefPlugin { public string Path { get; protected set; } public CompositionContainer Container { get; protected set; } [ImportMany()] protected IEnumerable Items; public MefPlugin(string PluginDirectry) { Path = PluginDirectry; var DC = new DirectoryCatalog(PluginDirectry); //var AC = new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()); var Catalog = new AggregateCatalog(DC);//,AC); Container = new CompositionContainer(Catalog); } public IEnumerable GetPlugins(){ Items = Container.GetExportedValues(); return Items; } } }