public int Read(IBufferWriter bufferWriter, int count) { int recount = 0; IBuffer sbuffer = GetReadBuffer(); int offset = 0; Memory <byte> memory = null; while (sbuffer != null) { memory = bufferWriter.GetMemory(count); int rc = Read(memory); offset += rc; count -= rc; recount += rc; bufferWriter.WriteAdvance(rc); if (count == 0) { break; } sbuffer = GetReadBuffer(); } return(recount); }