public class Event
{
private TimeSpan m_Offset = TimeSpan.Zero;
private TimeSpan m_Duration = TimeSpan.Zero;
private TimeSpan m_Countdown = TimeSpan.Zero;
private int m_OffsetFromUTC = -8;
DateTime m_EventStart, m_EventEnd;
private Server.Timer m_Timer;
private bool m_Calledstart = false;
private Item m_item;
private object m_context; // optional caller context object
private Action<object> m_startedCallback; // optional caller event started function
private Action<object> m_endedCallback; // optional caller event ended function
public Event(Item you, object context = null, Action<object> startedCallback = null, Action<object> endedCallback = null)
{
m_item = you;
m_context = context;
m_startedCallback = startedCallback;
m_endedCallback = endedCallback;
}
public void Serialize(GenericWriter writer)
{
writer.Write((int)1); // version
writer.Write(DateTime.Now);
writer.Write(m_Duration);
writer.Write(m_Calledstart);
writer.Write(m_OffsetFromUTC);
writer.Write(m_Offset);
}
public void Deserialize(GenericReader reader)
{
int version = reader.ReadInt();
switch (version)
{
case 1:
{
DateTime temp = reader.ReadDateTime();
m_Countdown = DateTime.Now - temp;
m_Duration = reader.ReadTimeSpan();
m_Calledstart = reader.ReadBool();
m_OffsetFromUTC = reader.ReadInt();
m_Offset = reader.ReadTimeSpan();
break;
}
}
}
}
What I need to do here is find a way to Serialize m_startedCallback and m_endedCallback, and then Deserialize them back into a usable form. I looked briefly at GetMethodInfo but it wasn't clear it would work on a variable, and even then, I don't know how to convert that back to a ligament function reference once I Deserialize.
Any help here would be appriciated.