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

設計模式(C#) - 命令模式(Command 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.Command;

public partial class Command : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
    Message m = new Message();

    Response.Write("操作");
    Response.Write("<br />");
    Response.Write(m.Do(Action.Insert, new MessageModel("第1條", DateTime.Now)));
    Response.Write("<br />");
    Response.Write(m.Do(Action.Insert, new MessageModel("第2條", DateTime.Now)));
    Response.Write("<br />");
    Response.Write(m.Do(Action.Insert, new MessageModel("第3條", DateTime.Now)));
    Response.Write("<br />");
    Response.Write(m.Do(Action.Insert, new MessageModel("第4條", DateTime.Now)));
    Response.Write("<br />");
    Response.Write(m.Do(Action.Delete, new MessageModel("第2條", DateTime.Now)));
    Response.Write("<br />");
    Response.Write(m.Do(Action.Insert, new MessageModel("第5條", DateTime.Now)));
    Response.Write("<br />");
    Response.Write(m.Do(Action.Delete, new MessageModel("第3條", DateTime.Now)));
    Response.Write("<br />");
    Response.Write(m.Do(Action.Insert, new MessageModel("第6條", DateTime.Now)));
    Response.Write("<br />");
    Response.Write(m.Do(Action.Insert, new MessageModel("第7條", DateTime.Now)));
    Response.Write("<br />");
    Response.Write("<br />");

    Response.Write("撤銷4次操作");
    Response.Write("<br />");
    Response.Write(m.Undo(4));
    Response.Write("<br />");
    Response.Write("<br />");

    Response.Write("重復2次操作");
    Response.Write("<br />");
    Response.Write(m.Redo(2));
    Response.Write("<br />");
    Response.Write("<br />");

    Response.Write("撤銷3次操作");
    Response.Write("<br />");
    Response.Write(m.Undo(3));
  }
}

運行結果

操作

Insert:第1條

Insert:第2條

Insert:第3條

Insert:第4條

Delete:第2條

Insert:第5條

Delete:第3條

Insert:第6條

Insert:第7條

撤銷4次操作

Delete:第7條 Delete:第6條 Insert:第3條 Delete:第5條

重復2次操作

Insert:第5條 Delete:第3條

撤銷3次操作

Insert:第3條 Delete:第5條 Insert:第2條

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