예제 #1
0
        public void ReadBulkTo(Stream target, int bulkLength, int bufferSize)
        {
            SAssert.ArgumentNotNull(() => target);
            SAssert.ArgumentNonNegative(() => bulkLength);
            SAssert.ArgumentPositive(() => bufferSize);

            using (var limiter = new LimitingStream(_stream, bulkLength))
                limiter.CopyTo(target);

            readCrLf();
        }
예제 #2
0
        public void WriteBulkFrom(Stream source, int count)
        {
            SAssert.ArgumentNotNull(() => source);
            SAssert.ArgumentNonNegative(() => count);

            using (var limiter = new LimitingStream(source, count)) {
                limiter.CopyTo(_stream);
                writeCrLf();

                SAssert.IsTrue(limiter.BytesLeft == 0,
                               () => new InvalidOperationException("Stream does not contains enough data."));
            }
        }