托管擴展框架_第1頁
托管擴展框架_第2頁
托管擴展框架_第3頁
托管擴展框架_第4頁
托管擴展框架_第5頁
已閱讀5頁,還剩15頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、李智樺MSDN資深講師K2 SourceCode2屬性(Attributes)屬性 是被指定給某一宣告的 Metadata 信息,隨后再運用Reflection的方式讀回來使用。 例: 串行化Serializable 字段檢核Display(Name = “身分證號/統(tǒng)一編號“) 輔助說明Help(item=“chap1” 甚至FrameworkImport、Export 、Compose3運用屬性 http:/ Programming Guide)提供功能強大的方法,將宣告信息與 C#代碼(類型、方法、屬性等)相關聯(lián)。二種屬性:CLR 的定義屬性: Defined in the common

2、 language runtime . 例: System.Serializable publicclass SampleClass 客制化屬性: 以宣告的方式對程序加入額外的信息,以便稍后運用程序讀取出來.例: AttributeUsage(AttributeTargets.All) publicclass HelpAttribute:System.Attribute 4程序設計: 如何使用屬性在 C#中宣告屬性非常簡單 , 它使用繼承自System.Attribute 的類別宣告形式并且已經(jīng)標記著AttributeUsage 屬性,如下所示: 5AgendaIntroductionWhat

3、 is MEF?What problems does MEF solve?How does MEF work?Architecture OverviewSamplesQ&A6What is MEF?A very specialInversion of Control Container is an approach in software development that favorsremoving sealed dependencies between classes in order to make code more simple and flexible.Moved the

4、control over theEngine creation outside of theCar and into the code that creates it. This is called.78 Inversion of Control By:控制反轉(縮寫為 IoC) ,也叫做依賴注入Dependency Injection簡稱DI。 目的在: 削減計算機程序的耦合問題。為Java著名的框架Spring 的核心 。9What is MEF?TheManaged Extensibility Framework (MEF) simplifies the creation of. MEF

5、 offersdiscovery andcomposition capabilities that you can leverage toload application extensions.10What is?(Part II) TheManaged Extensibility Framework isa new library in .NET ( System.ComponentModel.Composition )thatenables greater reuse of applicationsand components. Using MEF, .NETapplications ca

6、n make the shift from beingstatically compiled to dynamicallycomposed. If you are building extensibleapplications, extensible frameworks andapplication extensions, 11What problems does MEF solve?MEF provides a standard way for the host application to expose itself and consume external extensions. ME

7、F offers a set of discovery approaches for your application to locate and load available extensions.MEF allows tagging extensions with additonal metadata which facilitates rich querying and filtering12How does MEF work?MEFs core is comprised of a and a.A catalog is responsible for discovering extens

8、ions and the container coordinates creation and satisfies dependencies.MEFs first-class citizen is aComposablePart. A composable part offers up one or moreExports, and may also depend on one or more externally provided services orImports.Exports and imports each have aContract.MEFs container interac

9、ts withCatalogs to have access to composable parts.13 MEF diagram14Architecture Overview MEFs design can be divided into three distinct layers:*, which is most of the public API is available to the user;*, which provides a layer of indirection so MEF wont be tight coupled with a single approach to p

10、art discovery, imports/exports definitions and so forth; and finally our default implementation of the primitive layer that we call, which relies on types and attributes for discovery and definition of imports/exports.15三十六計勝戰(zhàn)計 一瞞天過海 二圍魏救趙 三借刀殺人 四以逸待勞 五趁火打劫 六聲東擊西敵戰(zhàn)計 七無中生有 八暗渡陳倉 九隔岸觀火 十笑里藏刀 十一李代桃僵 十二

11、順手牽羊攻戰(zhàn)計 十三打草驚蛇 十四借尸還魂 十五調虎離山 十六欲擒故縱 十七拋磚引玉十八擒賊擒王混戰(zhàn)計 十九釜底抽薪 二十渾水摸魚 廿一金蟬脫殼 廿二關門捉賊 廿三遠交近攻 廿四假道伐虢并戰(zhàn)計 廿五偷梁換柱 廿六指桑罵槐 廿七假癡不癲 廿八上屋抽梯 廿九樹上開花 三十反客為主敗戰(zhàn)計 卅一美人計 卅二空城計 卅三反間計 卅四苦肉計 卅五連環(huán)計 卅六走為上計16設計模式(Design Pattern)這個術語是在1990年代,由Erich Gamma等人,從建筑設計領域引入到計算器科學里去的。是對軟件設計中普遍存在(反復出現(xiàn))的各種問題,所提出的解決方案。設計模式并不直接用來完成程序代碼的編寫,而

12、是描述在各種不同情況下,要怎么解決問題的一種方案。17Managed Extensibility Framework Explorer Version 0.4.3555.17540Copyright (c) 2009 Microsoft Corporation. All rights reserved. Built for:System.ComponentModel.Composition,Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089 Usage:mefx.exe assembly files and dir

13、ectories action options Example: mefx.exe /file:MyAssembly.dll /causes /verbose Switches: /? Print usage. /causes List root causes - parts with errors not related to the rejection of other parts. /dir:C:MyAppParts Specify directories to search for parts. /exporters:MyContract List exporters of the g

14、iven contract. /exports Find exported contracts. /file:MyParts.dll Specify assemblies to search for parts. /importers:MyContract List importers of the given contract. /imports Find imported contracts. /parts List all parts found in the source assemblies. /rejected List all rejected parts. /type:MyNa

15、mespace.MyType Print details of the given part type. /verbose Print verbose information on each part. /whitelist:RejectionWhitelist.txt Specify parts that may be validly rejected; requres the /rejected or /causes commands.18反射在計算器科學中,反射是指一種特定類型的計算器程序能夠在運行時以一種依賴于它的代碼的抽象特性和它的運行時(runtime)行為的方式被更改的特性。用比

16、喻來說,這種程序能夠觀察并且修改自己的行為。In computer science,Reflection is the process by whicha computer program canobserve andmodifyits ownstructure andbehavior.1920 2008 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 inte

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論