Esempio n. 1
0
        private static SubfieldId ReadExtraFields(Core.Utility.BinaryReader reader, MetadataFlags flags, ref int bytesRead)
        {
            var subfieldIdentifier = SubfieldId.None;

            if (flags.HasFlag(MetadataFlags.ExtraFieldsPresent))
            {
                subfieldIdentifier = (SubfieldId)reader.ReadUInt16();
                bytesRead         += sizeof(SubfieldId);

                var subfieldDataLength = reader.ReadUInt16();                   // little-endian
                bytesRead += sizeof(ushort);
                reader.BaseStream.Seek(subfieldDataLength, SeekOrigin.Current); // just skip
            }
            return(subfieldIdentifier);
        }
Esempio n. 2
0
        private static ushort ReadCrc16(Core.Utility.BinaryReader reader, MetadataFlags flags, ref int bytesRead)
        {
            ushort crc16 = 0;

            if (flags.HasFlag(MetadataFlags.Crc16Present))
            {
                crc16      = reader.ReadUInt16();
                bytesRead += sizeof(ushort);
            }
            return(crc16);
        }
Esempio n. 3
0
        /// <inheritdoc />
        /// <remarks>The precondition here is that the reader is positioned immediately after the LUIGI block type value.</remarks>
        public override int Deserialize(Core.Utility.BinaryReader reader)
        {
            Length = reader.ReadUInt16();
            var bytesRead = PayloadLengthSize;

            HeaderCrc  = reader.ReadByte();
            bytesRead += HeaderChecksumSize;
            ValidateHeaderCrc();

            if (Length > 0)
            {
                PayloadCrc = reader.ReadUInt32();
                bytesRead += PayloadChecksumSize;
                bytesRead += DeserializePayload(reader);
            }
            return(bytesRead);
        }