




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、.NET框架2.0新特性綜述盧斌Software Development EngineerMicrosoft CorporationBCL 新功能Serial portCompressionStrongly typed resourcesConsole supportThreadingDiagnosticsNetworking。Strongly Typed Resources 演 示public class List private object elements; private int count; public void Add(object element) if (count = e
2、lements.Length) Resize(count * 2); elementscount+ = element; public object thisint index get return elementsindex; set elementsindex = value; public int Count get return count; Generics “泛型” public class List private T elements; private int count; public void Add(T element) if (count = elements.Leng
3、th) Resize(count * 2); elementscount+ = element; public T thisint index get return elementsindex; set elementsindex = value; public int Count get return count; List intList = new List();intList.Add(1);intList.Add(2);intList.Add(“3);int i = (int)intList0;List intList = new List();intList.Add(1); / Ar
4、gument is boxedintList.Add(2); / Argument is boxedintList.Add(“3); / Should be an errorint i = (int)intList0; / Cast requiredList intList = new List();intList.Add(1); / No boxingintList.Add(2); / No boxingintList.Add(“3); / Compile-time errorint i = intList0; / No cast requiredC#Generics “泛型” 為什么要Ge
5、nerics?編譯時(shí)類型驗(yàn)證高性能 (不用裝箱box, 不用轉(zhuǎn)換downcasts)減少代碼累贅 (typed collections)VB, C#, MC+ 編寫和運(yùn)用 genericsGenerics國際標(biāo)準(zhǔn)化Generics in VBPublic Class List(Of ItemType) Private elements() As ItemType Private elementcount As Integer Public Sub Add(ByVal element As ItemType) If elementcount = elements.Length ThenResiz
6、e(elementcount * 2) elements(elementcount) = element count += 1 End Sub Public Default Property Item(ByVal index As Integer) As ItemType Get Return elements(index) End Get Set (ByVal Value As ItemType) elements(index) = Value End Set End Property Public ReadOnly Property Count As Integer Get Return
7、elementcount End Get End PropertyEnd ClassDim intList As New List(Of Integer) intList.Add(1) No boxing intList.Add(2) No boxing intList.Add(“3) Compile-time error Dim i As Integer = intList(0) No cast requiredVBGenerics in C+genericpublic ref class List array elements; int count;public: void Add(T e
8、lement) if (count = elements-Length) Resize(count * 2); elementscount+ = element; property T default int index T get() return elementsindex; void set(T value) elementsindex = value; property int Count int get() return count; ;List intList = gcnew List();intList-Add(1); / No boxingintList-Add(2); / N
9、o boxingintList-Add(“3); / Compile-time errorint i = intList0; / No cast requiredC+基礎(chǔ)類庫泛類 (Generics in BCL)System.Collections.Generic classesListDictionaryStackQueueSystem.Collections.Generic interfacesIListIDictionaryIDictionaryICollectionIEnumerableIEnumeratorIComparableIComparerNullable(Of T)Even
10、tHandlerDim intVal as Nullable(Of Integer) = 5If intVal.HasValue Then checks for a valuedelegate void EventHandler(Object sender, T e) where T : EventArgs;提高 CLR 性能長遠(yuǎn)目標(biāo): CLR性能指標(biāo)與非托管本機(jī)代碼一致減少多個(gè)托管進(jìn)程的marginal cost減少托管應(yīng)用程序起動(dòng)時(shí)間和工作集NGEN將 IL 編譯成本機(jī)代碼, 然后存盤好處: 無需反復(fù)將 IL 編譯成本機(jī)代碼, 類的布局也已定型, 起動(dòng)時(shí)間更短 CLR 2.0:顯著地減少了
11、private, non-shareable工作集ngen install, ngen update, ngen /queue使.NET框架成為更快的編程平臺(tái)提高現(xiàn)有API的性能降低應(yīng)用程序域(AppDomain)開銷,應(yīng)用程序域之間的方法調(diào)用 (加快 1.1倍-50倍)委托(delegate)創(chuàng)建 (10倍) 和調(diào)用 (2倍)UTF8Encoding: translation (2.5倍)新的高性能 API更快的資源查找APILightweight CodeGen: 只生成關(guān)鍵代碼 (與 Reflect Emit 對比)TryParse 演 示走向 64 位64 位 Windows 服務(wù)器和
12、工作站支持 IA64 和 X64 (AMD64)Windows Server 2003 SP1和未來的64 位 Windows Client支持 WoW6432位應(yīng)用程序可在 64位機(jī)上運(yùn)行CLR1.0 和1.1應(yīng)用程序在 WoW64上運(yùn)行VS: 作為32位應(yīng)用程序運(yùn)行可以開發(fā), 調(diào)試和部署32位和64位應(yīng)用程序新的CLR 64位實(shí)時(shí)編譯, 垃圾回收和程序調(diào)試服務(wù)64bitNONOWOW64YESPE32+ILONLY32BITREQUIREDYESNOYESC# Compiler /platform: : ILONLY, NOT 32BITREQUIRED : 32BITREQUIRED o
13、r : PE32+Space Invaders 演 示CLR安全功能支持新的加密服務(wù)(cryptography)支持 PKI and PKCS7支持 XML 加密更好地支持 X509 certificatesDPAPI (Data Protection API)支持托管ACL提高應(yīng)用程序安全Permission 計(jì)算器 (PermCalc)Debug-In-ZoneSecureString 演 示RAD程序調(diào)試編輯繼續(xù)能力 (Edit and Continue)允許的編輯: (例子)給類加新的private字段給類加新的private非虛擬方法改寫方法內(nèi)的代碼不允許的編輯: (例子)除去字段或
14、方法編輯泛類 (generics)序列化(Serialization)不認(rèn)知新的字段Display Attributes 控制調(diào)試器顯示SQL Server 集成將開發(fā)工具 Visual Studio 與數(shù)據(jù)管理平臺(tái) SQL Server 集成在一起將中間層的.NET框架編程模式和開發(fā)技能應(yīng)用到數(shù)據(jù)層用托管代碼寫 Stored Procedures, Triggers, data types CLR安全系統(tǒng)(類型安全和代碼訪問安全)VS .NET 項(xiàng)目文件集: geo.dllVB, C#, BuildSQL ServerSQL 數(shù)據(jù): create assembly create functi
15、on create procedure create trigger create type SQL Queries: SELECT name FROM Supplier WHERE Location:Distance ( point ) 3SQL Server承載 CLRSQL CLR 功能 定義 Location.Distance()Sql 編程模式 分割字符串 (Splitting a string)老方法 (T-SQL). declare str varchar(200)select Str = Microsoft Corporation|SQL Server|2003|SQL-CLR
16、|2002-08-20|11:32:00|Document|3.b.3SELECTsubstring(Str + |, 0 + 1, charindex(|, Str + |, 0 + 1) - 0 - 1 ),substring(Str + |, charindex(|, Str + |) + 1, charindex(|, Str + |, charindex(|, Str + |) + 1) - charindex(|, Str + |) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) +
17、 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str +
18、|, charindex(|, Str + |) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, chari
19、ndex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, c
20、harindex(|, Str + |) + 1) + 1) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charind
21、ex(|, Str + |) + 1) + 1) + 1) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|,
22、 Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) - 1 ),substring(Str + |, charindex(
23、|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|
24、, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1) - 1 ) T-SQLdeclare str v
25、archar(200)select Str = Microsoft Corporation|SQL Server|2003|SQL-CLR|2002-08-20|11:32:00|Document|3.b.3SELECTsubstring(Str + |, 0 + 1, charindex(|, Str + |, 0 + 1) - 0 - 1 ),substring(Str + |, charindex(|, Str + |) + 1, charindex(|, Str + |, charindex(|, Str + |) + 1) - charindex(|, Str + |) - 1 ),
26、substring(Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1)
27、 + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |)
28、+ 1) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) - 1 ),substring(Str + |, charindex(|, Str + |
29、, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) - charindex(|, Str + |, char
30、index(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) - 1 ),substring(Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1, charindex
31、(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) + 1) - charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |, charindex(|, Str + |) + 1) + 1) + 1) + 1) + 1) -
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 養(yǎng)殖肉牛項(xiàng)目可行性報(bào)告
- 互聯(lián)網(wǎng)立項(xiàng)報(bào)告
- 母嬰護(hù)理中級復(fù)習(xí)試題含答案
- 護(hù)理-婦產(chǎn)科護(hù)理學(xué)練習(xí)卷含答案
- 醫(yī)療機(jī)構(gòu)信息管理系統(tǒng)應(yīng)急預(yù)案
- 建筑結(jié)構(gòu)穩(wěn)定性分析報(bào)告書
- 主管護(hù)師內(nèi)科護(hù)理復(fù)習(xí)試題及答案
- 鄉(xiāng)村衛(wèi)生保健推廣方案
- 針對網(wǎng)絡(luò)安全問題的解決方案與實(shí)施計(jì)劃
- 用戶體驗(yàn)優(yōu)化針對不同地區(qū)
- 租房合同范本下載(可直接打印)
- 食品安全管理制度打印版【7】
- DL-T5024-2020電力工程地基處理技術(shù)規(guī)程
- 病理學(xué)-第3章 局部血液循環(huán)障礙
- 湖北省黃石市基層診所醫(yī)療機(jī)構(gòu)衛(wèi)生院社區(qū)衛(wèi)生服務(wù)中心村衛(wèi)生室信息
- 打印版醫(yī)師執(zhí)業(yè)注冊健康體檢表(新版)
- 時(shí)代與變革-為人生而藝術(shù)
- 人教八年級下冊英語U5Do-you-remember-what-you-were-doing?課件
- 2009-2022歷年上海市公安機(jī)關(guān)勤務(wù)輔警招聘考試《職業(yè)能力傾向測驗(yàn)》真題含答案2022-2023上岸必備匯編3
- 小學(xué)人教版四年級下冊數(shù)學(xué)租船問題25題
- 露天礦開采技術(shù)課件匯總?cè)譸pt完整版課件最全教學(xué)教程整套課件全書電子教案
評論
0/150
提交評論