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

設計模式(C#) - 抽象工廠模式(Abstract Factory Pattern)(2)

編輯:關於C語言

AbstractMessageModel

using System;
using System.Collections.Generic;
using System.Text;

namespace Pattern.AbstractFactory
{
  /**//// <summary>
  /// 抽象Message實體類(AbstractProduct)
  /// </summary>
  public abstract class AbstractMessageModel
  {
    /**//// <summary>
    /// 構造函數
    /// </summary>
    public AbstractMessageModel()
    {

    }

    /**//// <summary>
    /// 構造函數
    /// </summary>
    /// <param name="msg">Message內容</param>
    /// <param name="pt">Message發布時間</param>
    public AbstractMessageModel(string msg, DateTime pt)
    {
      this._message = msg;
      this._publishTime = pt;
    }

    private string _message;
    /**//// <summary>
    /// Message內容
    /// </summary>
    public string Message
    {
      get { return _message; }
      set { _message = value; }
    }

    private DateTime _publishTime;
    /**//// <summary>
    /// Message發布時間
    /// </summary>
    public DateTime PublishTime
    {
      get { return _publishTime; }
      set { _publishTime = value; }
    }

    /**//// <summary>
    /// UserId
    /// </summary>
    public abstract string UserId
    {
      get;
      set;
    }
  }
}

SqlMessageModel

using System;
using System.Collections.Generic;
using System.Text;

namespace Pattern.AbstractFactory
{
  /**//// <summary>
  /// SqlMessage實體類(Product)
  /// </summary>
  public class SqlMessageModel : AbstractMessageModel
  {
    /**//// <summary>
    /// 構造函數
    /// </summary>
    public SqlMessageModel()
      : base()
    {

    }

    /**//// <summary>
    /// 構造函數
    /// </summary>
    /// <param name="userId">UserId</param>
    /// <param name="msg">Message內容</param>
    /// <param name="pt">Message發布時間</param>
    public SqlMessageModel(string userId, string msg, DateTime pt)
      : base(msg, pt)
    {
      this._userId = userId;
    }

    private string _userId;
    /**//// <summary>
    /// Message內容
    /// </summary>
    public override string UserId
    {
      get { return _userId; }
      set { _userId = value; }
    }
  }
}

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