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條