乐在其中设计模式(C#) - 责任链模式(Chain of Responsibility Pattern)
2014-03-09 18:14
966 查看
原文:乐在其中设计模式(C#) - 责任链模式(Chain of Responsibility Pattern)[索引页]
[源码下载]
[align=center]乐在其中设计模式(C#) - 责任链模式(Chain of Responsibility Pattern)[/align]
作者:webabcd
介绍
为解除请求的发送者和接收者之间耦合,而使多个对象都有机会处理这个请求。将这些对象连成一条链,并沿着这条链传递该请求,直到有一个对象处理它。
示例
有一个Message实体类,某个类对它的操作有Insert()方法。现在要求根据插入信息的字符长度,让不同的对象去处理,这些对象连成一条链,并沿着这条链传递该请求,直到有一个对象处理它。
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.ChainOfResponsibility
SqlMessage
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.ChainOfResponsibility
AbstractExecutor
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.ChainOfResponsibility
Employee
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.ChainOfResponsibility
Leader
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.ChainOfResponsibility
Manager
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.ChainOfResponsibility
client
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Pattern.ChainOfResponsibility;
public partial class ChainOfResponsibility : System.Web.UI.Page
运行结果
执行者:雇员 内容:abcd 时间:2007-4-22 20:04:41
执行者:主管 内容:abcdefgh 时间:2007-4-22 20:04:41
执行者:经理 内容:abcdefghigkl 时间:2007-4-22 20:04:41
你所插入的Message不符合要求
参考
http://www.dofactory.com/Patterns/PatternChain.aspx
OK
[源码下载]
[源码下载]
[align=center]乐在其中设计模式(C#) - 责任链模式(Chain of Responsibility Pattern)[/align]
作者:webabcd
介绍
为解除请求的发送者和接收者之间耦合,而使多个对象都有机会处理这个请求。将这些对象连成一条链,并沿着这条链传递该请求,直到有一个对象处理它。
示例
有一个Message实体类,某个类对它的操作有Insert()方法。现在要求根据插入信息的字符长度,让不同的对象去处理,这些对象连成一条链,并沿着这条链传递该请求,直到有一个对象处理它。
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.ChainOfResponsibility
SqlMessage
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.ChainOfResponsibility
AbstractExecutor
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.ChainOfResponsibility
Employee
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.ChainOfResponsibility
Leader
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.ChainOfResponsibility
Manager
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.ChainOfResponsibility
client
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Pattern.ChainOfResponsibility;
public partial class ChainOfResponsibility : System.Web.UI.Page
运行结果
执行者:雇员 内容:abcd 时间:2007-4-22 20:04:41
执行者:主管 内容:abcdefgh 时间:2007-4-22 20:04:41
执行者:经理 内容:abcdefghigkl 时间:2007-4-22 20:04:41
你所插入的Message不符合要求
参考
http://www.dofactory.com/Patterns/PatternChain.aspx
OK
[源码下载]
相关文章推荐
- 我所理解的设计模式(C++实现)——责任链模式(Chain Of Responsibility Pattern)
- 设计模式【责任链模式Chain of Responsibility Pattern】
- C#设计模式——职责链模式(Chain Of Responsibility Pattern)
- 如何让孩子爱上设计模式 ——22.责任链模式(Chain of Responsibility Pattern)
- 设计模式6--责任链模式(The chain of responsibility pattern)
- 23种设计模式--责任链模式-Chain of Responsibility Pattern
- 【设计模式】责任链模式(Chain of Responsibility Pattern)
- 1.1设计模式在Unity中应用—Behavioral Pattern— Chain of Responsibility Pattern 责任链模式
- 23种设计模式(22)_行为型_责任链模式(Chain of Responsibility Pattern)
- C#设计模式——职责链模式(Chain Of Responsibility Pattern)
- 极速理解设计模式系列:12.责任链模式(Chain of Responsibility Pattern)
- 设计模式 - Chain of Responsibility Pattern(责任链模式)
- 设计模式(十四)-责任链模式(Chain of Responsibility Pattern)——推卸责任
- C#设计模式之二十职责链模式(Chain of Responsibility Pattern)【行为型】
- 我所理解的设计模式(C++实现)——责任链模式(Chain Of Responsibility Pattern)
- 极速理解设计模式系列:12.责任链模式(Chain of Responsibility Pattern)
- 设计模式学习—责任链模式(Chain of Responsibility Design Pattern)
- 设计模式 - Chain of Responsibility Pattern(责任链模式)
- C#设计模式之二十职责链模式(Chain of Responsibility Pattern)【行为型】
- java设计模式——责任链模式(Chain of Responsibility Pattern)