public static void Serialize(Stream stream, object obj) { BinaryWriter writer = new BinaryWriter(stream); switch (Compression) { case FormatCompression.Binary: byte[] packet = BinaryDeconstructor.Deconstruct(obj); writer.Write(packet.Length); writer.Write(packet); break; case FormatCompression.String: writer.Write(Deconstructor.Deconstruct(obj)); break; default: throw new SerializationException("Please choose a format compression"); } writer.Flush(); }
public static string GetObjectGraph(object obj) => Deconstructor.Deconstruct(obj);