SqlMessage
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.Adapter
{
/**//// <summary>
/// 源(Adaptee)角色
/// Sql方式操作Message
/// </summary>
public class SqlMessage
{
/**//// <summary>
/// 獲取Message
/// </summary>
/// <returns></returns>
public List<MessageModel> Get()
{
List<MessageModel> l = new List<MessageModel>();
l.Add(new MessageModel("SQL方式獲取Message", DateTime.Now));
return l;
}
/**//// <summary>
/// 插入Message
/// </summary>
/// <param name="mm">Message實體對象</param>
/// <returns></returns>
public bool Insert(MessageModel mm)
{
// 代碼略
return true;
}
}
}
IMessage
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.Adapter
{
/**//// <summary>
/// 目標(Target)角色
/// 操作Message的接口
/// </summary>
public interface IMessage
{
/**//// <summary>
/// 獲取Message
/// </summary>
/// <returns></returns>
List<MessageModel> Select();
/**//// <summary>
/// 插入Message
/// </summary>
/// <param name="mm">Message實體對象</param>
/// <returns></returns>
bool Add(MessageModel mm);
}
}