public static uint Serialize<T>(string path, IByteSerializable<T> serializableObject)
 {
     byte[] src = serializableObject.ToBytes();
     uint hash = Crc32.ComputeHash(src);
     File.WriteAllBytes(path, src);
     return hash;
 }
Exemple #2
0
        /// <summary>
        /// Serialize object to byte array
        /// </summary>
        /// <param name="instance">Instance to serialize</param>
        /// <returns>Bytes containing the object properties</returns>
        public static byte[] Serialize(IByteSerializable instance)
        {
            var index = 0;
            var bytes = new byte[instance.Size];

            instance.ToBytes(bytes, ref index);
            return(bytes);
        }