public DownloadConnection(DownloadRequest request, DownloadRange range, Stream stream, long startPosition) { if (startPosition < -1) { throw new ArgumentException("Negative download length is invalid.", nameof(startPosition)); } Request = request; Range = range; Stream = stream; TotalDownloaded = startPosition >= 0 ? startPosition : (Stream.CanSeek ? Stream.Length : 0); ShrinkStream(TotalDownloaded, CancellationToken.None).Wait(); if (Range.HasLength && (TotalWritten > Range.Length)) { throw new ArgumentException("Invalid stream specified. Size is bigger than the requested portion.", nameof(stream)); } }
public DownloadConnection(DownloadRequest request, DownloadRange range, Stream stream) : this(request, range, stream, -1) { }