程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> 關於C語言 >> 設計模式(C#) - 責任鏈模式(Chain of Responsibility Pattern)(5)

設計模式(C#) - 責任鏈模式(Chain of Responsibility Pattern)(5)

編輯:關於C語言

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
{
  protected void Page_Load(object sender, EventArgs e)
  {
    AbstractExecutor employee = new Employee();
    AbstractExecutor leader = new Leader();
    AbstractExecutor manager = new Manager();
    employee.SetSuccessor(leader);
    leader.SetSuccessor(manager);

    Response.Write(employee.Insert(new MessageModel("abcd", DateTime.Now)));
    Response.Write("<br />");
    Response.Write(employee.Insert(new MessageModel("abcdefgh", DateTime.Now)));
    Response.Write("<br />");
    Response.Write(employee.Insert(new MessageModel("abcdefghigkl", DateTime.Now)));
    Response.Write("<br />");
    Response.Write(employee.Insert(new MessageModel("abcdefghigklmnop", DateTime.Now)));
  }
}

運行結果

執行者:雇員 內容:abcd 時間:2007-4-22 20:04:41

執行者:主管 內容:abcdefgh 時間:2007-4-22 20:04:41

執行者:經理 內容:abcdefghigkl 時間:2007-4-22 20:04:41

你所插入的Message不符合要求

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved