Action
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.Command
{
/**//// <summary>
/// enum
/// 定義操作的兩種方法Insert和Delete
/// </summary>
public enum Action
{
/**//// <summary>
/// Insert
/// </summary>
Insert,
/**//// <summary>
/// Delete
/// </summary>
Delete
}
}
SqlMessage
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.Command
{
/**//// <summary>
/// 接收者(Receiver)角色
/// Sql方式操作Message
/// </summary>
public class SqlMessage
{
/**//// <summary>
/// 操作
/// </summary>
/// <param name="action">操作的方法</param>
/// <param name="mm">Message實體對象</param>
public void Operation(Action action, MessageModel mm)
{
switch (action)
{
case Action.Insert :
Insert(mm);
break;
case Action.Delete :
Delete(mm);
break;
}
}
/**//// <summary>
/// 插入Message
/// </summary>
/// <param name="mm">Message實體對象</param>
private void Insert(MessageModel mm)
{
// 代碼略
}
/**//// <summary>
/// 刪除Message
/// </summary>
/// <param name="mm">Message實體對象</param>
private void Delete(MessageModel mm)
{
// 代碼略
}
}
}