Ejemplo n.º 1
0
        public static int ReadBufferInt32(byte[] buffer, int bufferOffset)
        {
            var intBuffer = new byte[4];

            Buffer.BlockCopy(buffer, bufferOffset, intBuffer, 0, 4);
            return(LittleEndianByteOrder.GetInt32(intBuffer));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Expect the upcoming 4 bytes are int32, read it and return it;
        /// </summary>
        public static int ExpectInt32(this Stream target)
        {
            var buff = new byte[4];

            if (target.Read(buff) == 4)
            {
                return(LittleEndianByteOrder.GetInt32(buff));
            }
            else
            {
                throw new EndOfStreamException();
            }
        }