public void Read(BinaryParser input)
        {
            byte[] headerBytes = input.ReadBytes(17);

            // Throw if we couldnt read header bytes
            if (headerBytes.Length < 17)
            {
                throw new EndOfStreamException(SR.IO_EOF_ReadBeyondEOF);
            }

            _majorVersion = GetInt32(headerBytes, 9);
            if (_majorVersion > BinaryFormatterMajorVersion)
            {
                throw new SerializationException(SR.Format(SR.Serialization_InvalidFormat, BitConverter.ToString(headerBytes)));
            }

            // binaryHeaderEnum has already been read
            _binaryHeaderEnum = (BinaryHeaderEnum)headerBytes[0];
            _topId = GetInt32(headerBytes, 1);
            _headerId = GetInt32(headerBytes, 5);
            _minorVersion = GetInt32(headerBytes, 13);
        }
Exemple #2
0
        public void Read(BinaryParser input)
        {
            byte[] headerBytes = input.ReadBytes(17);

            // Throw if we couldnt read header bytes
            if (headerBytes.Length < 17)
            {
                throw new EndOfStreamException(SR.IO_EOF_ReadBeyondEOF);
            }

            _majorVersion = GetInt32(headerBytes, 9);
            if (_majorVersion > BinaryFormatterMajorVersion)
            {
                throw new SerializationException(SR.Format(SR.Serialization_InvalidFormat, BitConverter.ToString(headerBytes)));
            }

            // binaryHeaderEnum has already been read
            _binaryHeaderEnum = (BinaryHeaderEnum)headerBytes[0];
            _topId            = GetInt32(headerBytes, 1);
            _headerId         = GetInt32(headerBytes, 5);
            _minorVersion     = GetInt32(headerBytes, 13);
        }