private int ReadInternalSync(byte[] buffer, int offset, int count) { int i; int num; for (i = 0; i < count; i += num) { if (currentCommandStream.Position == currentCommandStream.Length) { currentCommandStream = new MemoryStream(); BinaryWriter binaryWriter = new BinaryWriter(currentCommandStream); while (currentCommandStream.Length < count - i && commandsToOutput.MoveNext()) { DeltaCalculator.WriteCommand(binaryWriter, commandsToOutput.Current); } binaryWriter.Flush(); currentCommandStream.Seek(0L, SeekOrigin.Begin); } num = currentCommandStream.Read(buffer, offset + i, count - i); if (num <= 0) { break; } } return(i); }
public override async Task <int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { if (currentCommandStream.Position == currentCommandStream.Length) { if (!commandsToOutput.MoveNext()) { return(0); } this.currentCommandStream = new MemoryStream(); var writer = new BinaryWriter(this.currentCommandStream); DeltaCalculator.WriteCommand(writer, commandsToOutput.Current); writer.Flush(); this.currentCommandStream.Seek(0, SeekOrigin.Begin); } return(await this.currentCommandStream.ReadAsync(buffer, offset, count)); }