Beispiel #1
0
        public MultiPartDownload(
            Uri url,
            int bufferSize,
            int numberOfParts,
            ISDBuilder downloadBuilder,
            ISDRequestBuilder requestBuilder,
            ISDChecker downloadChecker,
            List <SDDC> alreadyDownloadedRanges)
            : base(url, bufferSize, null, null, requestBuilder, downloadChecker)
        {
            if (numberOfParts <= 0)
            {
                throw new ArgumentException("numberOfParts <= 0");
            }

            if (downloadBuilder == null)
            {
                throw new ArgumentNullException("downloadBuilder");
            }

            this.numberOfParts           = numberOfParts;
            this.downloadBuilder         = downloadBuilder;
            this.AlreadyDownloadedRanges = alreadyDownloadedRanges ?? new List <SDDC>();

            if (System.Net.ServicePointManager.DefaultConnectionLimit < numberOfParts)
            {
                System.Net.ServicePointManager.DefaultConnectionLimit = numberOfParts;
            }
        }
Beispiel #2
0
        public SDCheckData CheckDownload(Uri url, ISDRequestBuilder requestBuilder)
        {
            try
            {
                var request = requestBuilder.CreateRequest(url, null);

                using (var response = request.GetResponse())
                {
                    return(CheckDownload(response));
                }
            }
            catch (WebException ex)
            {
                return(new SDCheckData()
                {
                    Exception = ex, StatusCode = (int)(ex.Response as HttpWebResponse)?.StatusCode
                });
            }
            catch (Exception ex)
            {
                return(new SDCheckData()
                {
                    Exception = ex
                });
            }
        }
        public AbstractDownload(Uri url, int bufferSize, long?offset, long?maxReadBytes, ISDRequestBuilder requestBuilder, ISDChecker downloadChecker)
        {
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }

            if (bufferSize < 0)
            {
                throw new ArgumentException("bufferSize < 0");
            }

            if (offset.HasValue && offset.Value < 0)
            {
                throw new ArgumentException("offset < 0");
            }

            if (maxReadBytes.HasValue && maxReadBytes.Value < 0)
            {
                throw new ArgumentException("maxReadBytes < 0");
            }

            this.url             = url;
            this.bufferSize      = bufferSize;
            this.offset          = offset;
            this.maxReadBytes    = maxReadBytes;
            this.requestBuilder  = requestBuilder;
            this.downloadChecker = downloadChecker;

            this.state = SDState.Initialized;
        }
        public SimpleDownloadBuilder(ISDRequestBuilder requestBuilder, ISDChecker downloadChecker)
        {
            if (requestBuilder == null)
            {
                throw new ArgumentNullException("requestBuilder");
            }

            if (downloadChecker == null)
            {
                throw new ArgumentNullException("downloadChecker");
            }

            this.requestBuilder  = requestBuilder;
            this.downloadChecker = downloadChecker;
        }
        public SDMultipart(int numberOfParts, ISDBuilder downloadBuilder, ISDRequestBuilder requestBuilder, ISDChecker downloadChecker, List <SDDC> alreadyDownloadedRanges)
        {
            if (numberOfParts <= 0)
            {
                throw new ArgumentException("numberOfParts <= 0");
            }

            this.numberOfParts   = numberOfParts;
            this.downloadBuilder = downloadBuilder ?? throw new ArgumentNullException("Download builder cannot be null!");

            this.requestBuilder = requestBuilder ?? throw new ArgumentNullException("Request builder cannot be null!");

            this.downloadChecker = downloadChecker ?? throw new ArgumentNullException("Request checker cannot be null!");

            this.alreadyDownloadedRanges = alreadyDownloadedRanges ?? new List <SDDC>();
        }
Beispiel #6
0
 public SimpleDownload(Uri url, int bufferSize, long?offset, long?maxReadBytes, ISDRequestBuilder requestBuilder, ISDChecker downloadChecker)
     : base(url, bufferSize, offset, maxReadBytes, requestBuilder, downloadChecker)
 {
 }