DEV205企业程序库(EnterpriseLibrary)

上传人:ldj****22 文档编号:48727611 上传时间:2018-07-20 格式:PPT 页数:46 大小:1.44MB
返回 下载 相关 举报
DEV205企业程序库(EnterpriseLibrary)_第1页
第1页 / 共46页
DEV205企业程序库(EnterpriseLibrary)_第2页
第2页 / 共46页
DEV205企业程序库(EnterpriseLibrary)_第3页
第3页 / 共46页
DEV205企业程序库(EnterpriseLibrary)_第4页
第4页 / 共46页
DEV205企业程序库(EnterpriseLibrary)_第5页
第5页 / 共46页
点击查看更多>>
资源描述

《DEV205企业程序库(EnterpriseLibrary)》由会员分享,可在线阅读,更多相关《DEV205企业程序库(EnterpriseLibrary)(46页珍藏版)》请在金锄头文库上搜索。

1、DEV 205 企业程序库(Enterprise Library)王筱东 战略合作伙伴技术经理 平台及开发技术部 微软(中国)有限公司日程l企业程序库前世今生l企业程序库的7种武器l合作伙伴成功案例(中软融鑫)lQ configData.Name = fontDialog.Font.Name; configData.Size = fontDialog.Font.Size; configData.Style = Convert.ToInt32(fontDialog.Font.Style); /write an object info to config file ConfigurationMan

2、ager.WriteConfiguration(“EditorSettings“, configData);Public EditorFontData() Private string fontName;Private Double fontSize;Private Integer fontStyle; / Read an object with multiple properties EditorFontData configData = ConfigurationManager.GetConfiguration(“EditorSettings“)SecuritySecurityCrypto

3、CryptoConfigurationConfigurationData Data AccessAccessLoggingLoggingCachingCachingExceptionsExceptions碧玉刀数据访问程序块ConfigConfig ToolTool数据访问程序块大开大阖l对数据库访问提供了简单、高效的访问方式屏蔽了对常用ADO.NET使用的复杂度,使用单条语句即可完成对存储过程的调用l为SQL Server, Oracle, DB2提供了统一的编程当移植应用程序到不同数据库类型时,减少重写代码的数量l搭起了逻辑数据库与物理数据库间的桥梁,降低改变物理数据目标的难度l容易对数据

4、库访问的配置信息进行调整和验证数据访问程序块架构数据访问程序块示例Public Function GetProductsInCategory(ByRef Category As Integer) As DataSet Create the Database object, using the default database service. The default database service is determined through configuration.Dim db As Database = DatabaseFactory.CreateDatabase() Invoke t

5、he stored procedure with one line of code!return db.ExecuteDataSet(“GetProductsByCategory“, Category) Note: connection was closed by ExecuteDataSet method call End FunctionSecuritySecurityCryptoCryptoConfigurationConfigurationData Data AccessAccessLoggingLoggingCachingCachingExceptionsExceptions长生剑异

6、常处理程序块ConfigConfig ToolTool异常处理程序块攻如风,守似磐l异常处理程序块为系统的不同层面提供了一致的例外处理策略l异常由配置工具进行定义和维护 不需要通过编码控制例外处理l定义 “异常策略”,可指定该策略发生时的行为将异常写入日志用另外一个异常进行封装采用不同的异常替代以便隐藏敏感的异常信息创建自己的Handler ,提供附加的处理行为异常处理程序块示例DataSet customersDataSet try customersDataSet = RunQuery(“GetAllCustomers”); catch(Exception ex) string forma

7、ttedInfo = FormatException(ex); Logging.Log(formattedInfo) Throw new DataAccessException(“Database access failure for query GetAllCustomers”,e) Without Exception Handling App Block1.0DataSet customersDataSet try / Some code that may throw / Some code that may throwcustomersDataSet = RunQuery(“GetAll

8、Customers”); catch(Exception ex) if (ExceptionPolicy.HandleException(ex, “Data Access Policy”) throw; Exception policy: “Data Access Policy” Exception type: System.Data.SqlClient.SqlException Exception Handler: Logging HandlerWrap Handlerexceptionhandlin g.configWith Exception Handling App BlockSecu

9、ritySecurityCryptoCryptoConfigurationConfigurationData Data AccessAccessLoggingLoggingCachingCachingExceptionsExceptions离别钩缓存程序块ConfigConfig ToolTool缓存程序块心神合一l灵活的缓存机制可以用于以下各种类型的应用架构: Windows Forms Console application NT Service / COM+ Server ASP.NET Web application or Web servicel支持两类缓存机制:In-memory

10、cache 非永久缓存,但性能很好Backing store 永久性缓存, 但较慢l易于使用提供了Cache处理需的所有功能 (添加,查询,删除)可配置的过期策略SecuritySecurityCryptoCryptoConfigurationConfigurationData Data AccessAccessLoggingLoggingCachingCachingExceptionsExceptions孔雀翎加密程序块ConfigConfig ToolTool加密程序块第一暗器l简化了开发人员为敏感信息进行加解密工作加解密任何类型(Stream/Byte)的信息提高易用性(CreateHa

11、sh / CompareHash) l支持多种加解密算法支持所有.NET提供的加密算法通过DPAPI,对单台计算机上的信息进行无密钥加密允许集成自己开发的加解密算法Providerl提高集成性算法与密钥可以通过配置工具进行配置SecuritySecurityCryptoCryptoConfigurationConfigurationData Data AccessAccessLoggingLoggingCachingCachingExceptionsExceptions多情环安全程序块ConfigConfig ToolTool安全程序块人情色彩 l帮助开发人员在应用程序中实现通用的安全相关任务

12、 认证授权角色管理Profile管理l简单的方法AuthenticateAuthorizeGetRolesSetProfilel基于应用安全的最佳实践安全程序块架构SecuritySecurityCryptoCryptoConfigurationConfigurationData Data AccessAccessLoggingLoggingCachingCachingExceptionsExceptions拳头日志程序块ConfigConfig ToolTool日志程序块一切尽在掌握l提供简单标准一致的Logging机制l能灵活指定哪类信息以何种格式输出、输出到何处实现了应用程序代码与日志策

13、略的隔离l当前提供了以下日志输出:Event LogDatabaseText FileMSMQEmailWMI自定义输出日志程序块示例Dim log As LogEntry = New LogEntrylog.Message = “Your message here”log.Priority = 1log.EventId = 100log.Category = “Debug“Logger.Write(log)/ Or if you prefer one line. Customer cust = GetCustomer(123); / Log the customer will call /

14、cust.ToString() for the log entry Logger.Write(cust, Category, Priority);配置企业程序库日程l企业程序库前世今生l企业程序库的7种武器l合作伙伴成功案例(中软融鑫)lQ & A我们的应用lRed SMS Platform V3.0短信服务平台,完成短信收发lSMS 系统管理助手 V1.0Server Management System 助手,帮助用户完成如 License管理等辅助功能Red SMS Platform V3.0小试牛刀小试牛刀 日志程序块日志程序块 配置程序块配置程序块以前的做法l写类来完成文本文件写入Lo

15、gger.Write(string log))l修改方法参数或在使用中不断增加重载方法以应变可能的使用情况Write(p1)、Write(p1,p2)、l考虑如何将类对象序列化l自己处理XML文件的读写来读取和写入配置信息现在的做法1.1. 学习相关知识学习相关知识Web CastWeb Cast(1.51.5个小时)个小时)2.2. 研究示例研究示例SamplesSamples(1 1小时)小时)3.3. 完成功能完成功能Red SMS PlatformRed SMS Platform(1010分钟)分钟)实现方法Logger.Write(contentLogger.Write(conten

16、t) )Logger.Write(LogEntryLogger.Write(LogEntry log) log)Logger.Write(objectLogger.Write(object message, string category) message, string category)1111种重载方式!种重载方式!SMS系统管理助手 V1.0解决用户权限定义问题解决用户权限定义问题 安全程序块安全程序块 配置程序块配置程序块 加密程序块加密程序块 数据访问程序块数据访问程序块 日志程序块日志程序块安全程序块代码量 & 编码时间从企业程序库学到的l利用已有的成熟代码l形成企业或组织自己的组件库l通用组件要应用先进的设计p&p Enterprise Library我们一起努力扩充企业程

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号