MessageModel
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.Mediator
{
/**//// <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; }
}
}
}
AbstractMessageMediator
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.Mediator
{
/**//// <summary>
/// 抽象中介者(Mediator)
/// </summary>
public abstract class AbstractMessageMediator
{
/**//// <summary>
/// 注冊一個操作Message的對象
/// </summary>
/// <param name="AbstractMessage">AbstractMessage</param>
public abstract void Register(AbstractMessage AbstractMessage);
/**//// <summary>
/// 發送Message
/// </summary>
/// <param name="from">來自UserId</param>
/// <param name="to">發送到UserId</param>
/// <param name="mm">Message實體對象</param>
/// <returns></returns>
public abstract string Send(string from, string to, MessageModel mm);
}
}