Esempio n. 1
0
        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();
        }
Esempio n. 2
0
 public static string GetObjectGraph(object obj) => Deconstructor.Deconstruct(obj);