private void DoMaintenance(byte[] array, int offset, int count)
{
// If no bytes written, do nothing:
if (count <= 0)
return;
// Note that stream contains more than zero data bytes:
_wroteBytes = true;
// If no header/footer formatter present, nothing else to do:
if (_formatWriter == null)
return;
// If formatter has not yet written a header, do it now:
if (!_wroteHeader)
{
byte[] b = _formatWriter.GetHeader();
_stream.Write(b, 0, b.Length);
_wroteHeader = true;
}
// Inform formatter of the data bytes written:
_formatWriter.UpdateWithBytesRead(array, offset, count);
}