19 using System.Collections.Generic;
26 private readonly IList<MemoryStream> _buffers;
27 private int _currentBuffer;
34 public override int Read(
byte[] b,
int off,
int len)
36 if (len == 0)
return 0;
37 MemoryStream buffer = GetNextNonEmptyBuffer();
38 long remaining = buffer.Length - buffer.Position;
41 int remainingCheck = buffer.Read(b, off, (
int) remaining);
43 if(remainingCheck != remaining)
44 throw new InvalidDataException(
string.Format(
"remainingCheck [{0}] and remaining[{1}] are different.",
45 remainingCheck, remaining));
46 return (
int)remaining;
49 int lenCheck = buffer.Read(b, off, len);
52 throw new InvalidDataException(
string.Format(
"lenCheck [{0}] and len[{1}] are different.",
58 private MemoryStream GetNextNonEmptyBuffer()
60 while (_currentBuffer < _buffers.Count)
62 MemoryStream buffer = _buffers[_currentBuffer];
63 if (buffer.Position < buffer.Length)
68 throw new EndOfStreamException();
71 public override long Length 73 get {
throw new NotSupportedException(); }