private void WriteArrayAsBytes(Array array, int typeLength)
{
InternalWriteItemNull();
int byteLength = array.Length*typeLength;
int arrayOffset = 0;
if (byteBuffer == null)
byteBuffer = new byte[chunkSize];
while (arrayOffset < array.Length)
{
int numArrayItems = Math.Min(chunkSize/typeLength, array.Length-arrayOffset);
int bufferUsed = numArrayItems*typeLength;
Buffer.InternalBlockCopy(array, arrayOffset*typeLength, byteBuffer, 0, bufferUsed);
#if BIGENDIAN
// we know that we are writing a primitive type, so just do a simple swap
for (int i = 0; i < bufferUsed; i += typeLength)
{
for (int j = 0; j < typeLength / 2; j++)
{
byte tmp = byteBuffer[i + j];
byteBuffer[i + j] = byteBuffer[i + typeLength-1 - j];
byteBuffer[i + typeLength-1 - j] = tmp;
}
}
#endif
WriteBytes(byteBuffer, 0, bufferUsed);
arrayOffset += numArrayItems;
}
}