MessageModelLeaf
using System;
using System.Collections.Generic;
using System.Text;
namespace Pattern.Composite
{
/**//// <summary>
/// Message實體樹葉(Leaf)
/// </summary>
public class MessageModelLeaf : MessageModelComponent
{
/**//// <summary>
/// 構造函數
/// </summary>
/// <param name="name">名稱</param>
/// <param name="mm">Message實體對象</param>
public MessageModelLeaf(string name, MessageModel mm)
: base(name, mm)
{
}
/**//// <summary>
/// 添加
/// </summary>
/// <param name="mmc">MessageModelComponent</param>
public override void Add(MessageModelComponent mmc)
{
throw new Exception("不能添加");
}
/**//// <summary>
/// 刪除
/// </summary>
/// <param name="mmc">MessageModelComponent</param>
public override void Remove(MessageModelComponent mmc)
{
throw new Exception("不能刪除");
}
/**//// <summary>
/// 獲取
/// </summary>
/// <param name="indent">縮進數</param>
/// <returns></returns>
public override string GetData(int indent)
{
return new String('—', indent) +
"樹葉名稱:" + _name +
";信息內容:" + _messageModel.Message +
"<br />";
}
}
}