摘要: 组合部件通过[ExportAttribute]声明exports。在MEF中,有这么几种成员可声明exports的方式:组合部件(类)、字段、属性和方法。我们来看下ExportAttribute类的声明:[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Method | AttributeTargets.Class, AllowMultiple=true, Inherited=false)]public class ExportAttribute : Attribute{} 阅读全文
posted @ 2014-04-12 23:20 jello chen 阅读(483) 评论(0) 推荐(0) 编辑
摘要: 组合部件在MEF中,一个组合部件就是一个组合单元,组合部件"出口"其它组合部件需要的服务并且从其它部件"进口"需要的服务。在MEF编程模型中,为了声明组合部件的"出口"和"进口",使用的是ExportAttribute和ImportAttribute。一个组合部件至少应该包含一个[Export]。组合部件既可以被显式的添加到Container,也可以通过使用Catalogs来创建。MEF附带的默认的Catalogs是通过[Export]来识别组合部件的。契约组合部件并不直接依赖另一个组合部件,而是依赖一个由字符串标 阅读全文
posted @ 2014-04-12 15:27 jello chen 阅读(437) 评论(0) 推荐(1) 编辑
摘要: 在MEF出现以前,其实微软已经发布了一个类似的框架,叫MAF(Managed Add-in Framework),它旨在使应用程序孤立和更好的管理扩展,而MEF更关心的是可发现性、扩展性和轻便性,后者更lightweight。我们将跟随MEF官网来学习。The Managed Extensibility Framework or MEF is a library for creating lightweight, extensible applications. It allows application developers to discover and use extensions wi 阅读全文
posted @ 2014-04-12 12:32 jello chen 阅读(576) 评论(0) 推荐(0) 编辑