예제 #1
0
        public static long ReadBufferInt64(byte[] buffer, int bufferOffset)
        {
            var longBuffer = new byte[8];

            Buffer.BlockCopy(buffer, bufferOffset, longBuffer, 0, 8);
            return(LittleEndianByteOrder.GetInt64(longBuffer));
        }
예제 #2
0
        /// <summary>
        /// Expect the upcoming 8 bytes are int64, read it and return it;
        /// </summary>
        public static long ExpectInt64(this Stream target)
        {
            var buff = new byte[8];

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