CompositionContainer 公开了一部分获取导出、导出对象以及两者集合的重载。
var container = new CompositionContainer(new AssemblyCatalog(typeof(Program).Assembly)); Root partInstance = container.GetExportedValue<Root>();
[Export("my_contract_name")] public class Root { } var container = new CompositionContainer(new AssemblyCatalog(typeof(Program).Assembly)); Root partInstance = container.GetExportedValue<Root>("my_contract_name");
Lazy<Root> export = container.GetExport<Root>(); var root = export.Value; //create the instance.
var root = container.GetExportedValueOrDefault<Root>(); // may return null
MEF 编程指南(十一):查询 CompositionContainer,布布扣,bubuko.com
MEF 编程指南(十一):查询 CompositionContainer
原文:http://www.cnblogs.com/JavCof/p/3700788.html