Managed Extensibility Framework 托管可扩展性框架

Slides:



Advertisements
Similar presentations
Web Role 的每台虚机运行有 IIS ,用于处理 Web 请求 Worker Role 用于运行后台进程 Cloud Service 是什么? 支持多层架构的应用容器 由多个 Windows 虚拟机集群构成 集群有两种类型: Web 和 Worker Cloud Service 做什么 进行应用的自动化部署.
Advertisements

应用技术 陕西华辉科技有限公司.
泛舆情管理平台 ——助力媒体业务创新 新模式 新格局 创新盈利增长点 2/26/2017 1:59 AM 屈伟: 创始人,总裁
中国银行业前置端操作系统移植研究.
3/3/ :01 PM © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
请点击以下链接下载WinHEC的演讲材料
借助公有云实现游戏的弹性运营 Shaun Fang (方兴) Azure开发技术顾问
请点击以下链接下载WinHEC的演讲材料
1. 设定愿景,确定业务场景 Microsoft Corporation
广东省广州市花都区教育局教研室 汤少冰 优化评估方式, 促进中学英语的教与学 广东省广州市花都区教育局教研室 汤少冰
張書源 Microsoft MVP MCT 趨勢科技 技術經理 網酷科技 資深顧問 集英信誠 資深顧問
Excel VBA视频教程 课程介绍-什么是VBA
Office 2013 全新功能介紹 台灣微軟 Office 大使 楊承恩 Marcus Microsoft Office
講師姓名:黃信嘉、黃振宇 職稱:微軟技術支援副理 公司名稱:台灣微軟 課程代碼:WCL305
四川省集体林权流转平台 中国西部林权交易网
全国信息技术标准化技术委员会 (SAC/TC28)工作交流
Windows 10 混合现实 Mingfei Yan 高级项目经理
W371 如何使网络设备更好的和Windows Vista工作
MBL 340 Tablet PC SDK:在您的应用程序中使用数字墨水
今天很高兴能够利用Web Cast和大家讲解嵌入式XP的新增功能。
什麼是電子軟體下載 Electronic Software Download (ESD).
OFC 302 InfoPath2007新特性及解决方案.
最新 Windows Server 徽标 要求和计划
Windows Mobile 轻松接轨GPS
Microsoft Office SharePoint Server 2007 事件追蹤與專案管理
SOLUTIONACCELERATORS Windows Vista Hardware Assessment 1
MSG 321 统一消息架构和PBX集成.
朝雲端專業DBA邁進: 深入剖析 Windows Azure SQL Database 完整資料庫管理、雲端報表建立、建置分散式雲端資料庫
利用最新Hyper-V Replica 功能達成Hyper-V 災難備援機制
Windows Server 2008 NAP整合802.1x網路安全控管
互聯網安全資訊 助您達至更安全的網上體驗.
服務啟用、導入流程、 郵件移轉步驟簡介 Microsoft Office 12/2/2018
MBL 325 开发跨平台的 Windows Mobile应用程序
MBL 327 Windows Mobile开发中的异构系统集成
Cameron Brodeur Program Manager US-Device & Storage PM
David Edfeldt Senior Program Manager Windows Logo Program
构建 Windows TV Tuner 产业 生态环境的重要观点
微软新一代云计算 面向企业的 Office 365 客户培训大纲
1/2/ :39 PM 讀經 以弗所書 4:31-32 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may.
1/2/ :38 PM 耶利米書 33:1-3 約翰福音 14:12-14 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
使徒行傳 21:17-23章「保羅的見證(一)」 引言 預言保羅為主的名受許多的苦難的實現
超完美整合 SQL Server 2008 MOSS 2007 及 Excel 2007 打造好用又省錢的 企業商業智慧解決方案
SVR 352 扩展Windows Server 终端服务在企业中的应用
2/24/2019 5:40 AM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Exchange 2007 系統部署 -- 儲存預測與測試
教师课堂教学能力提升培训 ---“互联网+教育”考勤小测验 Plickers 洛阳理工学院
Microsoft SQL Server 2008 報表服務_設計
利用 ASP.NET MVC 提升您的 Web 應用程式


橫跨電腦、手機與軟體的全方位端點管控解決方案
请点击以下链接下载WinHEC的演讲材料
CON223 UDDI:服务的发现和搜索.
呂政周 精誠恆逸教育訓練處 資深講師 Windows PowerShell 呂政周 精誠恆逸教育訓練處 資深講師
使用WPF创建Windows应用和Web应用
水深之處 Launch Out into the Deep
4/30/2019 7:40 AM 約翰福音 15:9;17:20-23 加拉太書 6:1-2 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
DEV 343 VS2005超快速开发方案/EEP2006控件包.
5/4/2019 4:42 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
使徒行傳 24-26章 [ 保羅的見證(二)] 徒9:15 “  主 對 亞 拿 尼 亞 說 、 你 只 管 去 . 他 是 我 所 揀 選 的 器 皿 、 要 在 外 邦 人 和 君 王 並 以 色 列 人 面 前 、 宣 揚 我 的 名 。 ”]
TechEd /6/ :36 PM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Windows 徽标计划工具:综述与发展趋势
5/5/2019 7:06 PM 两跨框架梁截面配筋图的绘制 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may.
百万亿次超级计算机诞生记 姓名 Xiangyu Ye 职务 微软中国技术中心资深HPC顾问 公司 微软中国
5/15/2019 姓名: 公司名称: 云赛空间BP模板 Now let’s take a look at who we are, what we’re doing and why we’re doing it in China... This is an image of a technology.
DEV 343 VS2005超快速开发方案/EEP2006控件包.
MGT 213 System Management Server的昨天,今天和明天
Bob Combs Lead Program Manager Microsoft Corporation
Ron Jacobs 高级技术专员 Microsoft
Windows Workflow Foundation CON 230
Presentation transcript:

Managed Extensibility Framework 托管可扩展性框架 1/13/2019 1:33 PM Managed Extensibility Framework 托管可扩展性框架 秦春林 2011-04-28 © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

MEF Makes Extensibility Fabulous

Glenn Block --MEF产品经理

一般可扩展应用程序架构 框架设计者 App Framework Third Model Navigation Model Main Work Model 导航模块设计者 模块设计者 第三方插件设计者

RIA Extensions, add-ins, and plugins oh my!

Extensibility implants

Turning fat apps into slimmer apps

Import Export Need Got

An Application is built of parts. MEF Basics… An Application is built of parts.

Demo

MEF Basics… Export it. Import it. Compose it.

Widget1 Export it. Export 导出部件必须 包含公共 无参构造函数 [Export(typeof(UserControl))] public class Widget1 : UserControl { public MainPage(){ InitializeComponent(); } public string Message { get{return(string) Button.Content;} set{Button.Content=value;} 导出部件必须 包含公共 无参构造函数 Widget1 Export

Widget1 Import it. Import String [Export(typeof(UserControl))] public class Widget1 : UserControl { [Import] public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } Widget1 String Import

Widget1 Import it. Import “HelloMEF.Message” [Export(typeof(UserControl))] public class Widget1 : UserControl { [Import(“HelloMEF.Message”)] public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } Widget1 “HelloMEF.Message” Import

Main Page Import it. ImportMany UserControl [Export(typeof(UserControl))] public class MainPage: UserControl { [ImportMany(typeof(UserControl))] public IEnumerable<UserControl> { get;set; } Main Page UserControl ImportMany

PartIntializer: “Compose yourself” Compose it. PartIntializer: “Compose yourself” public MainPage() { InitializeComponent(); var catalog = new DirectoryCatalog("."); var container = new CompositionContainer(catalog); container.ComposeParts(this); } Main Page Compose

Be different – Use metadata

Where does the widget go?

Widget1 Export it - Metadata Export Put me in the top UserControl [ExportMetadata(“Location”,Location.Top)] [Export(typeof(UserControl))] public class Widget1 : UserControl { public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } Widget1 Put me in the top UserControl Export

Main Page Import it - Metadata ImportMany UserControl [Export(typeof(UserControl))] public class MainPage: UserControl { [ImportMany(typeof(UserControl))] public IEnumerable<Lazy<UserControl, IWidgetMetadata> get;set; } Main Page UserControl ImportMany

Have it your way! – Custom Exports

Widget1 Export it - Metadata Export Put me in the top UserControl [ExportMetadata(“Location”,Location.Top)] [Export(typeof(UserControl))] public class Widget1 : UserControl { public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } Widget1 Put me in the top UserControl Export

Customize it – Custom exports [Widget(Location=Location.Top)] public class Widget1 : UserControl { public string Message { get{return(string) Button.Content;} set{Button.Content=value;} } Widget1 Put me in the top UserControl Export

Demo

1/13/2019 1:33 PM MEF and Prism © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Introducing MEF-Prism integration Goal : Enable an existing Prism application to be further extended through MEF Enabled MEF modules to be added dynamically on the fly. Enable MEF discovered components to be registered in IoC container (Such as Unity).

Introducing MEF-Prism integration Prism application starts and loads up known modules. Module Loader

Introducing MEF-Prism integration Prism application can load unknown plugins, by using MEF as an abstraction layer. 1. Plugins are located and added to a MEF catalog. Server

Introducing MEF-Prism integration Prism application can load unknown plugins, by using MEF as an abstraction layer. 2. Plugins register dependencies with current IoC container. Server

Introducing MEF-Prism integration Prism application can load unknown plugins, by using MEF as an abstraction layer. 3. Plugins are activated. Dependencies are injected. Server

Where can I get it? MEF ships in Silverlight 4.0 Dynamic XAP support in SL 4.0 Toolkit Silverlight 3.0 support on Codeplex MEF source ships under MSPL Learn more: Silverlight.net MEF.Codeplex.com MEFContrib.Codeplex.com – Prism/MEF blogs.msdn.com/gblock

MEF Cross-platform(s) 1/13/2019 1:33 PM MEF Cross-platform(s) © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

深入MEF

MEF的几个核心概念 可组合的部件 导出 导入 约定 组合

使用MEF的一般步骤 添加需要容器创建的约定的导入 创建MEF用于发现部件的目录 创建组合部件实例的容器 通过对容器调用Composeparts方法并传入具有导入的实例,来进行组合

.NET Composition Architecture 托管层 Hosting 编程模型 Attributed Model 基元层 Primitives .NET Composition Architecture

基元层-生成部件和编程模型的位置 System.ComponentModel.Composition.Primitives 基元层是MEF的核心和基础。基元定义部件的抽象表现形式 在这个架构中开发者可以使用不同的编程模型来使用基元,MEF提供一种基于特性编程的编程模型

特性化编程模型 Attributed Programming Model System.ComponentModel.Composition 编程模型定义部件,导入和导出 特性化编程模型使用特性(Attribute)根据契约将一般的.NET对象标记为部件—特性化部件 编程模型配合托管层进行查找部件和组合部件

托管层-进行组合的位置 System.ComponentModel.Composition.Hosting 托管层提供了很大的灵活性,可配置性和可扩展性 目录提供可用导出和导出的部件定义。它们是MEF中用于发现的主要单元 TypeCatalog AssemblyCatalog DirectoryCatalog 目录从ComposablepartCatalog继承,并且是MEF的扩展点。自定义目录有多种用途: 从提供全新的编程模型到封装和赛选现有目录

通过构造函数导入 也成为构造函数注入 使用导入构造函数时,MEF会假设所有参数都是导入,从而不必使用Import特性 构造函数参数不支持重新组合

控制部件创建策略 默认情况下,容器中的所有部件实例都是单例,因为由在容器中导入它们的所有部件共享。 如果有时每个导入程序都要获取自己的实例,可以设置创建策略 CreationPolicy.Shared CreationPolicy.NonShared CreationPolocy.Any

导入延迟导出和访问元数据 System.Lazy<T> 使用该API可延迟实例的实例化,直至访问Lazy的Value属性 MEF使用Lazy<T,TMetadata>进一步扩展Lazy<T>,以允许在不实例化基础导出的情况下访问导出元数据 Tmetadata是元数据的视图类型。元数据视图是接口,用于定义对应所导出元数据中的键的只读属性。访问元数据属性时,MEF将动态实现Tmetadata,且将基于导出提供的元数据来设置值

重新组合 此功能允许部件在系统中出现新的匹配导出时自动更新其导入。 重新组合在某些方案中十分有用,例如从远程服务器下载部件时,可以启动多个可选视图的下载 AllowRecomposition=true 进行组合时,导入集合将立即替换为包含一组更新过的新的集合 有两个目录支持重新组合: DirectoryCatalog通过调用其Refresh方法来重新组合 AggregateCatalog使用Catalogs集合属性向该目录添加目录启动重新组合

MEF的世界 小到属性值的注入 构造函数参数的注入 服务的注入 大到模块的集成 第三方插件扩展 MEF提供的是一个可扩展性的框架 更是一种设计的指导 模块化,实现和接口分离,更好的扩展性,开放性

你还想到了什么?

MEF资源 MEF项目主页: 在.NET4中使用托管可扩展性框架构建可组合的应用程序 1/13/2019 1:33 PM MEF资源 MEF项目主页: http://mef.codeplex.com 在.NET4中使用托管可扩展性框架构建可组合的应用程序 http://msdn.microsoft.com/zh-cn/magazine/ee291628.aspx Managed Extensibility Framework: Overview http://channel9.msdn.com/Blogs/pdc2008/TL33 Building Extensible RIAs with the Managed Extensibility Framework http://www.microsoftpdc.com/2009/FT24 MEF程序设计指南(博客园): http://www.cnblogs.com/beniao/archive/2010/08/11/1797537.html © 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Thanks