AsmResolver.BinaryStreamReaderExtensions.TryReadCompressedUInt32 C# (CSharp) 메소드

TryReadCompressedUInt32() 공개 정적인 메소드

Tries to reads a compressed unsigned integer from the stream.
public static TryReadCompressedUInt32 ( this reader, uint &value ) : bool
reader this The reader to use for reading the data.
value uint The unsigned integer that was read from the stream.
리턴 bool
        public static bool TryReadCompressedUInt32(this IBinaryStreamReader reader, out uint value)
        {
            value = 0;
            if (!reader.CanRead(sizeof(byte)))
                return false;

            var firstByte = reader.ReadByte();
            reader.Position--;

            if (((firstByte & 0x80) == 0 && reader.CanRead(sizeof(byte))) ||
                ((firstByte & 0x40) == 0 && reader.CanRead(sizeof(ushort))) ||
                (reader.CanRead(sizeof(uint))))
            {
                value = ReadCompressedUInt32(reader);
                return true;
            }

            return false;
        }