BraintreeEncryption.Library.BouncyCastle.Asn1.IndefiniteLengthInputStream.Read C# (CSharp) Method

Read() public method

public Read ( byte buffer, int offset, int count ) : int
buffer byte
offset int
count int
return int
        public override int Read(
			byte[]	buffer,
			int		offset,
			int		count)
        {
            // Only use this optimisation if we aren't checking for 00
            if (_eofOn00 || count < 3)
                return base.Read(buffer, offset, count);

            if (_eofReached)
                return 0;

            int numRead = _in.Read(buffer, offset + 2, count - 2);

            if (numRead <= 0)
            {
                // Corrupted stream
                throw new EndOfStreamException();
            }

            buffer[offset] = (byte)_b1;
            buffer[offset + 1] = (byte)_b2;

            _b1 = _in.ReadByte();
            _b2 = _in.ReadByte();

            if (_b2 < 0)
            {
                // Corrupted stream
                throw new EndOfStreamException();
            }

            return numRead + 2;
        }