using System;
using System.Xml;
namespace Server.Accounting
{
public class AccountComment
{
private string m_Content;
///
/// Constructs a new AccountComment instance.
///
/// Initial AddedBy value.
/// Initial Content value.
public AccountComment(string addedBy, string content)
{
AddedBy = addedBy;
m_Content = content;
LastModified = Core.Now;
}
///
/// Deserializes an AccountComment instance from an xml element.
///
/// The XmlElement instance from which to deserialize.
public AccountComment(XmlElement node)
{
AddedBy = Utility.GetAttribute(node, "addedBy", "empty");
LastModified = Utility.GetXMLDateTime(Utility.GetAttribute(node, "lastModified"), Core.Now);
m_Content = Utility.GetText(node, "");
}
///
/// Deserializes an AccountComment instance.
///
/// The deserialization reader
public AccountComment(IGenericReader reader)
{
AddedBy = reader.ReadString();
LastModified = reader.ReadDateTime();
m_Content = reader.ReadString();
}
///
/// A string representing who added this comment.
///
public string AddedBy { get; }
///
/// Gets or sets the body of this comment. Setting this value will reset LastModified.
///
public string Content
{
get => m_Content;
set
{
m_Content = value;
LastModified = Core.Now;
}
}
///
/// The date and time when this account was last modified -or- the comment creation time, if never modified.
///
public DateTime LastModified { get; private set; }
///
/// Serializes this AccountComment instance.
///
/// The serialization writer.
public void Serialize(IGenericWriter writer)
{
writer.Write(AddedBy ?? "empty");
writer.Write(LastModified);
writer.Write(m_Content);
}
}
}