SqlMessage
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.Mediator
{
/**//// <summary>
/// Sql方式操作Message(ConcreteColleague)
/// </summary>
public class SqlMessage : AbstractMessage
{
/**//// <summary>
/// 構造函數
/// </summary>
/// <param name="userId">UserId</param>
public SqlMessage(string userId)
: base(userId)
{
}
/**//// <summary>
/// 接受Message(由中介者調用)
/// </summary>
/// <param name="from">來自UserId</param>
/// <param name="mm">Message實體對象</param>
/// <returns></returns>
public override string Insert(string from, MessageModel mm)
{
return "Sql方式插入Message(" + from + "發送給" + base.UserId + ")"
+ " - 內容:" + mm.Message
+ " - 時間:" + mm.PublishTime.ToString();
}
}
}
XMLMessage
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.Mediator
{
/**//// <summary>
/// XML方式操作Message(ConcreteColleague)
/// </summary>
public class XMLMessage : AbstractMessage
{
/**//// <summary>
/// 構造函數
/// </summary>
/// <param name="userId">UserId</param>
public XMLMessage(string userId)
: base(userId)
{
}
/**//// <summary>
/// 接受Message(由中介者調用)
/// </summary>
/// <param name="from">來自UserId</param>
/// <param name="mm">Message實體對象</param>
/// <returns></returns>
public override string Insert(string from, MessageModel mm)
{
return "XML方式插入Message(" + from + "發送給" + base.UserId + ")"
+ " - 內容:" + mm.Message
+ " - 時間:" + mm.PublishTime.ToString();
}
}
}