MEF目录
MEF目录
MEF编程的最大价值就是能够动态发现目录内的组合部件,应用程序可以通过目录对部件注册导
出。
Assembly Catalog 程序集目录
var catalog = new AssemblyCatalog
(System.Reflection.Assembly.GetExecutingAssembly());
Directory Catalog 目录(silverlight不提供该类)
var catalog = new DirectoryCatalog("Extensions");
如果是一个相对目录,改目录不会自动刷新,需要自己实现目录扫描机制
var catalog = new DirectoryCatalog("Extensions");
//some scanning logic
catalog.Refresh();
Aggregate Catalog 集合目录
当程序集目录和目录不能满足单独和合并目录时使用集合目录构成一个单一的目录。
最实用的模式,当前程序集和第三方程序集构成目录。
var catalog = new AggregateCatalog(
new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()),
new DirectoryCatalog("Extensions"));
Type Catalog 类型目录
加载特定类型的目录
var catalog = new TypeCatalog(typeof(type1), typeof(type2), ...);
DeploymentCatalog 部署目录 - Silverlight only
动态加载远程xap包