




已阅读5页,还剩57页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
ManagedExtensibilityFramework托管可扩展性框架 秦春林 2011 04 28 MEFMakesExtensibilityFabulous GlennBlock MEF产品经理 一般可扩展应用程序架构 AppFramework 框架设计者 第三方插件设计者 模块设计者 导航模块设计者 RIAExtensions add ins andpluginsohmy Extensibilityimplants Turningfatappsintoslimmerapps NeedGot ImportExport MEFBasics AnApplicationisbuiltofparts Demo MEFBasics Exportit Importit Composeit Exportit Widget1 Export typeof UserControl publicclassWidget1 UserControl publicMainPage InitializeComponent publicstringMessage get return string Button Content set Button Content value Export 导出部件必须包含公共无参构造函数 Importit Widget1 Export typeof UserControl publicclassWidget1 UserControl Import publicstringMessage get return string Button Content set Button Content value Import String Importit Widget1 Export typeof UserControl publicclassWidget1 UserControl Import HelloMEF Message publicstringMessage get return string Button Content set Button Content value Import HelloMEF Message Importit MainPage Export typeof UserControl publicclassMainPage UserControl ImportMany typeof UserControl publicIEnumerable get set ImportMany UserControl Composeit PartIntializer Composeyourself MainPage Compose publicMainPage InitializeComponent varcatalog newDirectoryCatalog varcontainer newCompositionContainer catalog container ComposeParts this Bedifferent Usemetadata Widget Widget Wheredoesthewidgetgo Exportit Metadata Widget1 ExportMetadata Location Location Top Export typeof UserControl publicclassWidget1 UserControl publicstringMessage get return string Button Content set Button Content value Export UserControl Putmeinthetop Importit Metadata MainPage Export typeof UserControl publicclassMainPage UserControl ImportMany typeof UserControl publicIEnumerable get set ImportMany UserControl Haveityourway CustomExports Exportit Metadata Widget1 ExportMetadata Location Location Top Export typeof UserControl publicclassWidget1 UserControl publicstringMessage get return string Button Content set Button Content value Export UserControl Putmeinthetop Customizeit Customexports Widget1 Widget Location Location Top publicclassWidget1 UserControl publicstringMessage get return string Button Content set Button Content value Export UserControl Putmeinthetop Demo MEFandPrism IntroducingMEF Prismintegration Goal EnableanexistingPrismapplicationtobefurtherextendedthroughMEFEnabledMEFmodulestobeaddeddynamicallyonthefly EnableMEFdiscoveredcomponentstoberegisteredinIoCcontainer SuchasUnity IntroducingMEF Prismintegration Prismapplicationstartsandloadsupknownmodules IntroducingMEF Prismintegration Prismapplicationcanloadunknownplugins byusingMEFasanabstractionlayer 1 PluginsarelocatedandaddedtoaMEFcatalog Server IntroducingMEF Prismintegration Prismapplicationcanloadunknownplugins byusingMEFasanabstractionlayer 2 PluginsregisterdependencieswithcurrentIoCcontainer Server IntroducingMEF Prismintegration Prismapplicationcanloadunknownplugins byusingMEFasanabstractionlayer 3 Pluginsareactivated Dependenciesareinjected Server WherecanIgetit MEFshipsinSilverlight4 0DynamicXAPsupportinSL4 0ToolkitSilverlight3 0supportonCodeplexMEFsourceshipsunderMSPLLearnmore SMEF CMEFContrib C Prism MEF MEFCross platform s 深入MEF MEF的几个核心概念 可组合的部件导出导入约定组合 使用MEF的一般步骤 添加需要容器创建的约定的导入创建MEF用于发现部件的目录创建组合部件实例的容器通过对容器调用Composeparts方法并传入具有导入的实例 来进行组合 基元层Primitives 编程模型AttributedModel 托管层Hosting NETCompositionArchitecture 基元层 生成部件和编程模型的位置 System ComponentModel Composition Primitives基元层是MEF的核心和基础 基元定义部件的抽象表现形式在这个架构中开发者可以使用不同的编程模型来使用基元 MEF提供一种基于特性编程的编程模型 特性化编程模型AttributedProgrammingModel System ComponentModel Composition编程模型定义部件 导入和导出特性化编程模型使用特性 Attribute 根据契约将一般的 NET对象标记为部件 特性化部件编程模型配合托管层进行查找部件和组合部件 托管层 进行组合的位置 System ComponentModel Composition Hosting托管层提供了很大的灵活性 可配置性和可扩展性目录提供可用导出和导出的部件定义 它们是MEF中用于发现的主要单元TypeCatalogAssemblyCatalogDirectoryCatalog目录从ComposablepartCatalog继承 并且是MEF的扩展点 自定义目录有多种用途 从提供全新的编程模型到封装和赛选现有目录 通过构造函数导入 也成为构造函数注入使用导入构造函数时 MEF会假设所有参数都是导入 从而不必使用Import特性构造函数参数不支持重新组合 控制部件创建策略 默认情况下 容器中的所有部件实例都是单例 因为由在容器中导入它们的所有部件共享 如果有时每个导入程序都要获取自己的实例 可以设置创建策略CreationPolicy SharedCreationPolicy NonSharedCreationPolocy Any 导入延迟导出和访问元数据 System Lazy使用该API可延迟实例的实例化 直至访问Lazy的Value属性MEF使用Lazy进一步扩展Lazy 以允许在不实例化基础导出的情况下访问导出元数据Tmetadata是元数据的视图类型 元数据视图是接口 用于定义对应所导出元数据中的键的只读属性 访问元数据属性时 MEF将动态实现Tmetadata 且将基于导出提供的元数据来设置值 重新组合 此功能允许部件在系统中出现新的匹配导出时自动更新其导入 重新组合在某些方案中十分有用 例如从远程服务器下载部件时 可以启动多个可选视图的下载AllowRecomposition true进行组合时 导入集合将立即替换为包含一组更新过的新的集合有两个目录支持重新
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025安康高新集团旗下子公司招聘(4人)模拟试卷及答案详解(易错题)
- 【教师招聘】2025年九江经济技术开发区中心幼儿园公开招聘顶岗教师考前自测高频考点模拟试题及答案详解(名师系列)
- 2025年九江市工业发展集团有限公司招聘工作人员模拟试卷及参考答案详解一套
- 焦煤集团职称考试题库及答案
- 法官入额考试题库及答案
- 最强大脑考试题库及答案
- 东莞医疗招聘考试题库及答案
- 孔子考试题库及答案大全
- 绿色低碳园区承诺函5篇范文
- 2025年锅炉水处理作业人员G3证考试试题题库有答案
- 建筑室外围蔽板材(简化)
- YS/T 397-2015海绵锆
- GB/T 3217-1992永磁(硬磁)材料磁性试验方法
- GB/T 250-2008纺织品色牢度试验评定变色用灰色样卡
- GB/T 2091-2008工业磷酸
- GB/T 19816.2-2005涂覆涂料前钢材表面处理喷射清理用金属磨料的试验方法第2部分:颗粒尺寸分布的测定
- 市政工程工程量计算规范课件
- 隐身技术概述课件
- 《红细胞血型系统》课件
- 古诗词诵读《江城子乙卯正月二十日夜记梦》课件-统编版高中语文选择性必修上册
- 《家庭暴力中的正当防卫问题分析(论文)9500字》
评论
0/150
提交评论