Message
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.Adapter
{
/**//// <summary>
/// 適配器(Adapter)角色
/// 類適配器
/// 把源適配到這個類
/// </summary>
public class Message : SqlMessage, IMessage
{
/**//// <summary>
/// 獲取Message
/// </summary>
/// <returns></returns>
public List<MessageModel> Select()
{
return base.Get();
}
/**//// <summary>
/// 插入Message
/// </summary>
/// <param name="mm">Message實體對象</param>
/// <returns></returns>
public bool Add(MessageModel mm)
{
return base.Insert(mm);
}
}
}
Message2
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.Adapter
{
/**//// <summary>
/// 適配器(Adapter)角色
/// 對象適配器
/// 把源適配到這個類
/// </summary>
public class Message2 : IMessage
{
private SqlMessage _sqlMessage;
/**//// <summary>
/// 構造函數
/// </summary>
public Message2()
{
_sqlMessage = new SqlMessage();
}
/**//// <summary>
/// 獲取Message
/// </summary>
/// <returns></returns>
public List<MessageModel> Select()
{
return _sqlMessage.Get();
}
/**//// <summary>
/// 插入Message
/// </summary>
/// <param name="mm">Message實體對象</param>
/// <returns></returns>
public bool Add(MessageModel mm)
{
return _sqlMessage.Insert(mm);
}
}
}