public ulong ReadUInt64(FileFormatException.EntityType entityType)
 {
     try {
         ulong result = this.BaseReader.ReadUInt64();
         return(result);
     } catch (EndOfStreamException) {
         throw new FileFormatException(entityType, FileFormatException.Error.UnexpectedEndOfFile, this.CurrentPosition);
     }
 }
        public byte[] ReadBytes(int count, FileFormatException.EntityType entityType)
        {
            byte[] result = this.BaseReader.ReadBytes(count);

            if (result.Length < count)
            {
                throw new FileFormatException(entityType, FileFormatException.Error.UnexpectedEndOfFile, this.CurrentPosition);
            }

            return(result);
        }
        public string ReadUTF16String(int numBytes, FileFormatException.EntityType entityType)
        {
            long?errorOffset = this.CurrentPosition;

            byte[] bytes = this.ReadBytes(numBytes, entityType);
            string result;

            try {
                result = Encoding.Unicode.GetString(bytes);
            } catch (ArgumentException ex) {
                throw new FileFormatException(entityType, FileFormatException.Error.InvalidValue, errorOffset, null, ex);
            }
            result = result.TrimEnd('\0');
            return(result);
        }