Apache.NMS.Commands.StreamMessage.ReadBytes C# (CSharp) Метод

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

public ReadBytes ( byte value ) : int
value byte
Результат int
        public int ReadBytes(byte[] value)
        {
            InitializeReading();

            if(value == null)
            {
                throw new NullReferenceException("Passed Byte Array is null");
            }

            try
            {
                if(this.bytesRemaining == -1)
                {
                    long startingPos = this.byteBuffer.Position;
                    byte type = this.dataIn.ReadByte();

                    if(type != PrimitiveMap.BYTE_ARRAY_TYPE)
                    {
                        this.byteBuffer.Seek(startingPos, SeekOrigin.Begin);
                        throw new MessageFormatException("Not a byte array");
                    }

                    this.bytesRemaining = this.dataIn.ReadInt32();
                }
                else if(this.bytesRemaining == 0)
                {
                    this.bytesRemaining = -1;
                    return -1;
                }

                if(value.Length <= this.bytesRemaining)
                {
                    // small buffer
                    this.bytesRemaining -= value.Length;
                    this.dataIn.Read(value, 0, value.Length);
                    return value.Length;
                }
                else
                {
                    // big buffer
                    int rc = this.dataIn.Read(value, 0, this.bytesRemaining);
                    this.bytesRemaining = 0;
                    return rc;
                }
            }
            catch(EndOfStreamException ex)
            {
                throw NMSExceptionSupport.CreateMessageEOFException(ex);
            }
            catch(IOException ex)
            {
                throw NMSExceptionSupport.CreateMessageFormatException(ex);
            }
        }