Nanook.QueenBee.Parser.BinaryEndianReader.ReadUInt32 C# (CSharp) Метод

ReadUInt32() публичный Метод

public ReadUInt32 ( EndianType endianType ) : UInt32
endianType EndianType
Результат System.UInt32
        public UInt32 ReadUInt32(EndianType endianType)
        {
            if ((BitConverter.IsLittleEndian && endianType != EndianType.Little) || (!BitConverter.IsLittleEndian && endianType != EndianType.Big))
            {
                byte[] b = base.ReadBytes(4);
                Array.Reverse(b);
                return BitConverter.ToUInt32(b, 0);
            }
            else
                return base.ReadUInt32();
        }

Usage Example

Пример #1
0
        public override void Construct(BinaryEndianReader br, QbItemType type)
        {
            //System.Diagnostics.Debug.WriteLine(string.Format("{0} - 0x{1}", type.ToString(), (base.StreamPos(br) - 4).ToString("X").PadLeft(8, '0')));

            base.Construct(br, type);

            _unknown = br.ReadUInt32(base.Root.PakFormat.EndianType);
            uint decompressedSize = br.ReadUInt32(base.Root.PakFormat.EndianType);
            uint compressedSize   = br.ReadUInt32(base.Root.PakFormat.EndianType);

            // Get script data
            Lzss lz = new Lzss();

            _scriptData = br.ReadBytes((int)compressedSize);
            if (compressedSize < decompressedSize)
            {
                _scriptData = lz.Decompress(_scriptData);
            }

            if (_scriptData.Length != decompressedSize)
            {
                throw new ApplicationException(string.Format("Location 0x{0}: Script decompressed to {1} bytes not {2}", (base.StreamPos(br) - compressedSize).ToString("X").PadLeft(8, '0'), _scriptData.Length.ToString(), decompressedSize.ToString()));
            }

            // Padding...
            if ((base.StreamPos(br) % 4) != 0)
            {
                br.BaseStream.Seek(4 - (base.StreamPos(br) % 4), SeekOrigin.Current);
            }

            base.ConstructEnd(br);
        }
All Usage Examples Of Nanook.QueenBee.Parser.BinaryEndianReader::ReadUInt32