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

設計模式(C#) - 裝飾模式(Decorator Pattern)(6)

編輯:關於C語言

Test

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.Decorator;

public partial class Decorator : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
    AbstractMessage message = new SqlMessage();

    AbstractMessageWrapper amr = new CheckUserWrapper(message);

    Response.Write(amr.Get()[0].Message + " " + amr.Get()[0].PublishTime.ToString());
    Response.Write("<br />");

    AbstractMessageWrapper amr2 = new CheckInputWrapper(message);

    Response.Write(amr2.Get()[0].Message + " " + amr2.Get()[0].PublishTime.ToString());
    Response.Write("<br />");

    AbstractMessageWrapper amr3 = new CheckUserWrapper(message);
    AbstractMessageWrapper amr4 = new CheckInputWrapper(amr3);

    Response.Write(amr4.Get()[0].Message + " " + amr4.Get()[0].PublishTime.ToString());
    Response.Write("<br />");
  }
}

運行結果

SQL方式獲取Message(經過用戶驗證) 2007-5-13 19:34:01

SQL方式獲取Message(經過輸入驗證) 2007-5-13 19:34:01

SQL方式獲取Message(經過用戶驗證)(經過輸入驗證) 2007-5-13 19:34:01

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