public override long GetBytes(int ordinal, long dataIndex, byte[] buffer, int bufferIndex, int length)
{
ValidateState(nameof(GetBytes));
ValidateReader();
byte[] tempBuffer;
try
{
tempBuffer = (byte[])_currentDataRow[ordinal];
}
catch (IndexOutOfRangeException e)
{
// thrown by DataColumnCollection
ExceptionBuilder.TraceExceptionWithoutRethrow(e);
throw ExceptionBuilder.ArgumentOutOfRange(nameof(ordinal));
}
if (buffer == null)
{
return tempBuffer.Length;
}
int srcIndex = (int)dataIndex;
int byteCount = Math.Min(tempBuffer.Length - srcIndex, length);
if (srcIndex < 0)
{
throw ADP.InvalidSourceBufferIndex(tempBuffer.Length, srcIndex, nameof(dataIndex));
}
else if ((bufferIndex < 0) || (bufferIndex > 0 && bufferIndex >= buffer.Length))
{
throw ADP.InvalidDestinationBufferIndex(buffer.Length, bufferIndex, nameof(bufferIndex));
}
if (0 < byteCount)
{
Array.Copy(tempBuffer, dataIndex, buffer, bufferIndex, byteCount);
}
else if (length < 0)
{
throw ADP.InvalidDataLength(length);
}
else
{
byteCount = 0;
}
return byteCount;
}