65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
using Server;
|
|
using System;
|
|
|
|
namespace Server.Engines.NewMagincia
|
|
{
|
|
public class NewMaginciaMessage
|
|
{
|
|
public static readonly TimeSpan DefaultExpirePeriod = TimeSpan.FromDays(7);
|
|
|
|
private TextDefinition m_Title;
|
|
private TextDefinition m_Body;
|
|
private string m_Args;
|
|
private DateTime m_Expires;
|
|
|
|
public TextDefinition Title { get { return m_Title; } }
|
|
public TextDefinition Body { get { return m_Body; } }
|
|
public string Args { get { return m_Args; } }
|
|
public DateTime Expires { get { return m_Expires; } }
|
|
|
|
public bool Expired { get { return m_Expires < DateTime.UtcNow; } }
|
|
|
|
public NewMaginciaMessage(TextDefinition title, TextDefinition body)
|
|
: this(title, body, DefaultExpirePeriod, null)
|
|
{
|
|
}
|
|
|
|
public NewMaginciaMessage(TextDefinition title, TextDefinition body, string args)
|
|
: this(title, body, DefaultExpirePeriod, args)
|
|
{
|
|
}
|
|
|
|
public NewMaginciaMessage(TextDefinition title, TextDefinition body, TimeSpan expires)
|
|
: this(title, body, expires, null)
|
|
{
|
|
}
|
|
|
|
public NewMaginciaMessage(TextDefinition title, TextDefinition body, TimeSpan expires, string args)
|
|
{
|
|
m_Title = title;
|
|
m_Body = body;
|
|
m_Args = args;
|
|
m_Expires = DateTime.UtcNow + expires;
|
|
}
|
|
|
|
public void Serialize(GenericWriter writer)
|
|
{
|
|
writer.Write((int)0);
|
|
|
|
TextDefinition.Serialize(writer, m_Title);
|
|
TextDefinition.Serialize(writer, m_Body);
|
|
writer.Write(m_Expires);
|
|
writer.Write(m_Args);
|
|
}
|
|
|
|
public NewMaginciaMessage(GenericReader reader)
|
|
{
|
|
int v = reader.ReadInt();
|
|
|
|
m_Title = TextDefinition.Deserialize(reader);
|
|
m_Body = TextDefinition.Deserialize(reader);
|
|
m_Expires = reader.ReadDateTime();
|
|
m_Args = reader.ReadString();
|
|
}
|
|
}
|
|
} |