/// <summary> /// Gets or builds a serialization expression tree to convert the specified instance to an array of bytes. /// </summary> public static byte[] Serialize(object value) { using (var writer = new StarWriter()) { Serialize(value, writer); return(writer.ToArray()); } }
public static void Serialize(object value, StarWriter writer) { try { Type type = value.GetType(); BuildAndStore(type); var lambda = PacketSerializers[type]; lambda(writer, value); } catch (Exception e) { throw new Exception(string.Format("Serialization error. Type: {0}", value.GetType()), e); } }
public abstract Task Write(StarWriter writer);