using System;
/// <summary>
/// 消息类
/// </summary>
public class Message : IMessage
{
public Message(string name)
: this(name, null, null)
{ }
public Message(string name, object body)
: this(name, body, null)
{ }
public Message(string name, object body, string type)
{
m_name = name;
m_body = body;
m_type = type;
}
public override string ToString()
{
string msg = "Notification Name: " + Name;
msg += "/nBody:" + ((Body == null) ? "null" : Body.ToString());
msg += "/nType:" + ((Type == null) ? "null" : Type);
return msg;
}
public virtual string Name
{
get { return m_name; }
}
public virtual object Body
{
get
{
return m_body;
}
set
{
m_body = value;
}
}
public virtual string Type
{
get
{
return m_type;
}
set
{
m_type = value;
}
}
private string m_name;
private string m_type;
private object m_body;
}
this串联构造方法
最新推荐文章于 2022-07-14 23:10:20 发布
本文介绍了一个消息类的设计与实现细节,该类用于封装通知名称、消息体及类型等属性,并提供构造函数来灵活初始化这些属性。此外,还实现了 ToString 方法以方便查看消息实例的状态。
2886

被折叠的 条评论
为什么被折叠?



