internal void WritePartialLong(long v, int length, TdsParserStateObject stateObj)
{
Debug.Assert(length <= 8, "Length specified is longer than the size of a long");
Debug.Assert(length >= 0, "Length should not be negative");
if ((stateObj._outBytesUsed + length) > stateObj._outBuff.Length)
{
// if all of the long doesn't fit into the buffer
for (int shiftValue = 0; shiftValue < length * 8; shiftValue += 8)
{
stateObj.WriteByte((byte)((v >> shiftValue) & 0xff));
}
}
else
{
// all of the long fits into the buffer
for (int index = 0; index < length; index++)
{
stateObj._outBuff[stateObj._outBytesUsed + index] = (byte)((v >> (index * 8)) & 0xff);
}
stateObj._outBytesUsed += length;
}
}