Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpbcgr.RdpbcgrServerDecoder.GetBytes C# (CSharp) Method

GetBytes() private method

Get specified length of bytes from a byte array (start index is updated according to the specified length)
private GetBytes ( byte data, int &startIndex, int bytesToRead ) : byte[]
data byte data in byte array
startIndex int start index
bytesToRead int specified length
return byte[]
        private byte[] GetBytes(byte[] data, ref int startIndex, int bytesToRead)
        {
            // if input data is null
            if (null == data)
            {
                throw new FormatException(ConstValue.ERROR_MESSAGE_DATA_NULL_REF);
            }

            // if index is out of range
            if ((startIndex < 0) || (startIndex + bytesToRead > data.Length))
            {
                throw new FormatException(ConstValue.ERROR_MESSAGE_DATA_INDEX_OUT_OF_RANGE);
            }

            // read bytes of specific length
            byte[] dataRead = new byte[bytesToRead];
            Array.Copy(data, startIndex, dataRead, 0, bytesToRead);

            // update index
            startIndex += bytesToRead;
            return dataRead;
        }
RdpbcgrServerDecoder