Exemplo n.º 1
0
        /// <summary>
        /// Reads an object instance from the specified byte buffer.
        /// </summary>
        /// <typeparam name="T">Type of the object to read</typeparam>
        /// <param name="buffer">The byte buffer to read the object instance.</param>
        /// <returns>An object instance of type T.</returns>
        public static T Read <T>([NotNull] byte[] buffer)
        {
            var reader = new BinarySerializationReader(new MemoryStream(buffer));

            return(reader.Read <T>());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reads an object instance from the specified stream.
        /// </summary>
        /// <typeparam name="T">Type of the object to read</typeparam>
        /// <param name="stream">The stream to read the object instance.</param>
        /// <returns>An object instance of type T.</returns>
        public static T Read <T>([NotNull] Stream stream)
        {
            var reader = new BinarySerializationReader(stream);

            return(reader.Read <T>());
        }