MessageModel
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.Observer
{
/**//// <summary>
/// Message實體類
/// </summary>
public class MessageModel
{
/**//// <summary>
/// 構造函數
/// </summary>
/// <param name="msg">Message內容</param>
/// <param name="pt">Message發布時間</param>
public MessageModel(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; }
}
}
}
IMessage
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.Observer
{
/**//// <summary>
/// 操作Message的接口(Observer)
/// </summary>
public interface IMessage
{
/**//// <summary>
/// 插入Message
/// </summary>
/// <param name="mm">Message實體對象</param>
/// <returns></returns>
string Insert(MessageModel mm);
}
}