SqlMessage
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.AbstractFactory
{
/**//// <summary>
/// Sql方式操作Message類(Product)
/// </summary>
public class SqlMessage : AbstractMessage
{
/**//// <summary>
/// 插入Message
/// </summary>
/// <param name="amm">AbstractMessageModel</param>
/// <returns></returns>
public override string Insert(AbstractMessageModel amm)
{
return "Sql方式插入Message。帳號:" + amm.UserId
+ ";內容:" + amm.Message
+ ";時間:" + amm.PublishTime.ToString();
}
}
}
XMLMessage
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.AbstractFactory
{
/**//// <summary>
/// XML方式操作Message類(Product)
/// </summary>
public class XMLMessage : AbstractMessage
{
/**//// <summary>
/// 插入Message
/// </summary>
/// <param name="amm">AbstractMessageModel</param>
/// <returns></returns>
public override string Insert(AbstractMessageModel amm)
{
return "XML方式插入Message。帳號:" + amm.UserId
+ ";內容:" + amm.Message
+ ";時間:" + amm.PublishTime.ToString();
}
}
}
AbstractMessageFactory
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.AbstractFactory
{
/**//// <summary>
/// 抽象Message工廠(AbstractFactory)
/// </summary>
public abstract class AbstractMessageFactory
{
/**//// <summary>
/// 創建MessageModel對象
/// </summary>
/// <returns></returns>
public abstract AbstractMessageModel CreateMessageModel();
/**//// <summary>
/// 創建Message對象
/// </summary>
/// <returns></returns>
public abstract AbstractMessage CreateMessage();
}
}