XMLMessage
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.State
{
/**//// <summary>
/// XML方式操作Message
/// </summary>
public class XMLMessage : AbstractMessageState
{
/**//// <summary>
/// 構造函數
/// </summary>
/// <param name="message">Context類型參數</param>
public XMLMessage(Message message)
{
this._message = message;
}
/**//// <summary>
/// 改變狀態
/// </summary>
public override void StateChangeCheck()
{
// 如果UserId是admin則變換狀態為SqlMessage
if (this._message.UserId == "admin")
{
this._message.AbstractMessageState = new SqlMessage(this._message);
}
}
/**//// <summary>
/// 獲取Message
/// </summary>
/// <returns></returns>
public override List<MessageModel> Get()
{
List<MessageModel> l = new List<MessageModel>();
l.Add(new MessageModel("XML方式獲取Message", DateTime.Now));
return l;
}
/**//// <summary>
/// 插入Message
/// </summary>
/// <param name="mm">Message實體對象</param>
/// <returns></returns>
public override bool Insert(MessageModel mm)
{
// 代碼略
return true;
}
}
}