Read() public method

public Read ( BufferReader reader ) : void
reader BufferReader
return void
Beispiel #1
0
        public bool ReadNextRecord(VssRecord record)
        {
            while (reader.Remaining > RecordHeader.LENGTH)
            {
                try
                {
                    var recordHeader = new RecordHeader();
                    recordHeader.Read(reader);

                    var recordReader = reader.Extract(recordHeader.Length);

                    // comment records always seem to have a zero CRC
                    if (recordHeader.Signature != CommentRecord.SIGNATURE)
                    {
                        recordHeader.CheckCrc();
                    }

                    if (recordHeader.Signature == record.Signature)
                    {
                        record.Read(recordReader, recordHeader);
                        return(true);
                    }
                }
                catch (EndOfBufferException e)
                {
                    throw new RecordTruncatedException(e.Message);
                }
            }
            return(false);
        }
Beispiel #2
0
        protected T GetRecord <T>(
            CreateRecordCallback <T> creationCallback,
            bool ignoreUnknown)
            where T : VssRecord
        {
            var recordHeader = new RecordHeader();

            recordHeader.Read(reader);

            var recordReader = reader.Extract(recordHeader.Length);

            // comment records always seem to have a zero CRC
            if (recordHeader.Signature != CommentRecord.SIGNATURE)
            {
                recordHeader.CheckCrc();
            }

            var record = creationCallback(recordHeader, recordReader);

            if (record != null)
            {
                // double-check that the object signature matches the file
                recordHeader.CheckSignature(record.Signature);
                record.Read(recordReader, recordHeader);
            }
            else if (!ignoreUnknown)
            {
                throw new UnrecognizedRecordException(recordHeader,
                                                      string.Format("Unrecognized record signature {0} in item file",
                                                                    recordHeader.Signature));
            }
            return(record);
        }
Beispiel #3
0
        public void ReadRecord(VssRecord record)
        {
            try
            {
                var recordHeader = new RecordHeader();
                recordHeader.Read(reader);

                var recordReader = reader.Extract(recordHeader.Length);

                // comment records always seem to have a zero CRC
                if (recordHeader.Signature != CommentRecord.SIGNATURE)
                {
                    recordHeader.CheckCrc();
                }

                recordHeader.CheckSignature(record.Signature);

                record.Read(recordReader, recordHeader);
            }
            catch (EndOfBufferException e)
            {
                throw new RecordTruncatedException(e.Message);
            }
        }