随笔分类 -  EnterpriseLibrary

软件代码生成之Codesmith模板.netTiers
摘要:.netTiers模板到2006年就诞生了, 到今天最后一次更新是12/17/2013, 支持.NET 4.5 and Visual Studio 2012 and 2013. netTiers是基于微软企业库的模板项目. 在今天各种PC端应用软件横行天下, 使用代码生成工具来提高开发效率是经常的事儿. netTiers构架设计是这样的: 运行codesmith... 阅读全文
posted @ 2014-09-14 15:28 PetterLiu 阅读(4465) 评论(2) 推荐(0) 编辑
基于Enterprise Library 6 的AOP实现
摘要:最近 Enterprise Library 6 正式版发布了,距离上了版本又有一段时间.首先我们来看下面这张模块图,实线表示强依赖,虚线表示弱依赖(或可选的). 6.0版本全面支持.net Framework 4.5. 相对于前面5.0版本,移除了下面的模块: The Caching Application Block The Cryptography ... 阅读全文
posted @ 2013-05-10 15:12 PetterLiu 阅读(12927) 评论(1) 推荐(2) 编辑
使用EnterpriseLibrary Validation Block对WCF做验证
摘要:EnterpriseLibrary Validation Application Block 5.0 用来对Application做验证是常见的应用。下面我们来实现在Windows Communication Foundation (WCF 4 )中验证集成。引用Microsoft.Practices.EnterpriseLibrary.Validation.dll 与 Micro... 阅读全文
posted @ 2012-08-07 15:29 PetterLiu 阅读(1347) 评论(0) 推荐(1) 编辑
Asp.net Web Applicatoin实现自定义HttpModule拦截异常处理
摘要:Asp.net的NamePipe机制给我们提供了很多扩展性. 使用HttpModule我们可能实现的有: 强制站点范围的Cookie策略 集中化监控与日志 编写设置与删除HTTP头 控制response输出,如删除多余空白字符 Session管理 认证与受权 下面我们来看如何实现自定义异常处理: 1: public class ErrorModule:IHttpModule 2... 阅读全文
posted @ 2011-11-12 16:55 PetterLiu 阅读(3545) 评论(0) 推荐(0) 编辑
使用Unity2.0的Interceptor实现简单AOP
摘要:Unity 2.0 现在已经是Enterprise Library 中一个模块了。我们可以使用Unity 2.0的Interceptor来拦截方法最终实现AOP。它的实现是这样的,看下面的图比较清楚: 让我们看下面的DEMO代码: 1: public interface IDAL 2: { 3: void MethodForLoggingA(); 4: void MethodForLogging... 阅读全文
posted @ 2011-06-06 16:28 PetterLiu 阅读(3385) 评论(2) 推荐(0) 编辑
Enterprise Library 5.0中使用Xml文件配置Unity2.0与ServiceLocator
摘要:早在Enterprise Library 5.0之前,就已经有了一个Common Service Locator.在这里假设您对Enterprise Library已经有一定了解。在Enterprise Library 5.0中,我们通常会使用EnterpriseLibraryContainer.Current,实际上它是IServiceLocator接口。例如下面的代码: 我们从容器中获取一个E... 阅读全文
posted @ 2010-12-20 17:39 PetterLiu 阅读(2086) 评论(2) 推荐(0) 编辑
使用Fluent配置API驱动Enterprise Library 5.0
摘要:在以前的Enterprise Library版本中,使用各个BLOCK需要配置XML.否则很难正常工作.在Enterprise Library 5.0中提供了一个ConfigurationSourceBuilder的class来扮演configuration sources.这样就可以实现Fluent配置API驱动Enterprise Library 5.0.也就是我们可以在程序中动态配置或替换这... 阅读全文
posted @ 2010-12-14 11:40 PetterLiu 阅读(938) 评论(0) 推荐(0) 编辑
Asp.net中Web项目使用EnterpriseLibrary5.0独立配置文件找不到问题
摘要:前几天在做一个Web Project升级过程中遇到这个问题,项目使用了Enterprise Library 4.1,并且有独立的配置文件。升级到5.0版本时发现找不到这个配置文件。运行时将得到这样的Exception(这里我们定义配置文件为EntLib.config): The configuration file EntLib.config could not be found. 解决方法有以下... 阅读全文
posted @ 2010-12-02 18:02 PetterLiu 阅读(2904) 评论(2) 推荐(0) 编辑
Unity在Xml配制文件使用泛型
摘要:Unity 在现在项目中,已经得到广泛使用。今天我们来看如何在XML配制文件配制泛型。如下我们这样的一个类型: 这是一个Repository模式,假设有以下的实现:在代码中注册是这样的:好的,现在我们从配制文件读取:关键的XML配制在这儿:注意加粗的字体就是我们泛型。让我们来测试一下:一切OK了,这就实用使用配制文件实现DI解析泛型。希望对您开发有帮助。作者:Petter Liu 出处:http... 阅读全文
posted @ 2010-11-05 20:08 PetterLiu 阅读(3143) 评论(2) 推荐(3) 编辑
无配置文件使用Enterprise Library Logging Application Block 4.1
摘要:以前曾经有同事问我,如何使用直接使用Enterprise Library Logging Application Block,而不需要写任何配置文件。我的回答是可以的。是的,今天让我们实现下。我们知道能常EntLib需要读取config中配置节信息,那我们可以在Code里传送相应的信息给它,看以下的代码: 注意,这里我们配置是使用RollingFlatFileTraceListener,也就是写磁... 阅读全文
posted @ 2010-09-24 12:22 PetterLiu 阅读(1099) 评论(0) 推荐(1) 编辑
Repository Factory介绍
摘要:Repository Factory是的Micrsoft Patterns and practies Team在前几年出的一个代码生成组件,主要生成基于Enlib DAAB的DataAccessLayer和Business Entity. 主要适用于VS2005,VS2008。从官方下载RepositoryFactoryForVS2008.msi,安装后,在Tools菜单将有一个选项Guidanc... 阅读全文
posted @ 2010-07-25 21:37 PetterLiu 阅读(3596) 评论(1) 推荐(1) 编辑
使用EnterpriseLibrary的PIAB与Unity搭建简单AOP框架
摘要:首先声明,Enterprise Library v5.0已发布了,此处的DEMO是基于Enterprise Library v4.1这个版本. 差别并不太多了.Enterprise Library 提供了图形的化配置工具,让我们免去写XML的配置文件.我们可以用policy injection application block和Unity搭建一个简单的AOP框架,而你不用写一句代码. AOP框架... 阅读全文
posted @ 2010-06-07 22:42 PetterLiu 阅读(4576) 评论(4) 推荐(4) 编辑
EneterpriseLibrary5的Fluent配制API
摘要:随着Enterprise Library5的发布,有一个新功能是提供了Fluent方式配制API.在这篇POST中,我将演示如何使用Fluent配制API来配制Data Access Applicat... 阅读全文
posted @ 2010-04-27 17:11 PetterLiu 阅读(918) 评论(0) 推荐(1) 编辑
Enterprise Library Logging 快速上手
摘要:这篇文章将演示花费最小的代价使用Microsoft’s Enterprise Library 4.1在你的应用程序中记录日志。下面是一些细节,第一次如何在代码logging Message: 下载安装Enterprise Library 4.1 让我们开始,创一个VS控制台程序名叫HelloWorldEntLibLogging,在项目中引用Ent. Lib. logging assembly,如... 阅读全文
posted @ 2010-02-24 09:54 PetterLiu 阅读(4292) 评论(0) 推荐(0) 编辑
Abstract Factory与Unity结合
摘要:采用短信示例场景,SGIP,CMPP是联通与移动协议,对应它们有自己的配置文件。ISmsProvider为所有协议接口,IConfig 配置文件接口。通过在配置文件中配置工厂,在Unity中实现Client类构造函数自动注入。 /// /// Interface for Factory /// /// author Louis Liu http:/... 阅读全文
posted @ 2008-11-08 22:54 PetterLiu 阅读(885) 评论(0) 推荐(0) 编辑