Good luck on your future projects man, you teach me a lot :D, but just please don't do this on reflection D:
public static NetworkMessage BuildMessage(uint id, IDataReader reader)
{
if (!m_messages.ContainsKey(id))
{
Console.WriteLine(string.Format("NetworkMessage <id:{0}> doesn't exist", id));
return null;
}
NetworkMessage message = m_constructors[id]();
if (message == null)
{
Console.WriteLine(string.Format("Constructors[{0}] (delegate {1}) does not exist", id, m_messages[id]));
return null;
}
var methode = message.GetType().GetMethod("Deserialize");
methode.Invoke(message, new object[1] { reader });
return message;
}
It's really really slow (and is not the only code that do it)