我目前MEF的工作和面临的一些问题如何加载使用MEF(托管扩展框架)从目录中的DLL
我想是从目录中加载的DLL。
第i个扫描目录和
名称属性从各自DLL保存两件事情在字典(如串)
和模块名称(如串)
这里是ScanDirectory()代码
private void ScanPluginDirectory()
{
catalog = new AggregateCatalog();
catalog.Catalogs.Add(new DirectoryCatalog(@"..\..\plugin"));
container = new CompositionContainer(catalog);
batch = new CompositionBatch();
batch.AddPart(this);
container.Compose(batch);
pluginDictionary = new Dictionary<String, String>();
foreach (IFilter filter in filters)
{
Type t = filter.GetType();
pluginDictionary.Add(filter.Name, t.Module.Name);
}
}
并在复选框列表中显示其名称。从复选框中选择dll。
我有作为
[Import]
public IEnumerable<IFilter> filters { get; set; }
目前我的程序运行正常import语句。我做的是当我检查复选框列表中的插件。它将它移动到“加载”目录中,并且它们的QueryPlugin()方法将查找“加载”目录以搜索插件。
取消选中复选框列表中的插件。我将其移出“装”目录...
我要的是使用batch.RemovePart()方法来获得从一个目录到其它的DLL摆脱这种快速移动的....
注:我不使用手动
batch.AddPart(new DemoFilter1());
代替该我用DirectoryCatalog(添加插件成批处理);;
尚无回答:( – Mohsan 2009-05-18 06:29:34