Example #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;
            }
        }
Example #2
0
        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>();
        }
Example #3
0
        public SDResumine(int timeForHeartbeat, int timeToRetry, int?maxRetries, ISDBuilder downloadBuilder)
        {
            if (timeForHeartbeat <= 0)
            {
                throw new ArgumentException("Keep Alive time must be bigger then 0!");
            }

            if (timeToRetry <= 0)
            {
                throw new ArgumentException("Retry time must be bigger then 0!");
            }

            this.timeForHeartbeat = timeForHeartbeat;
            this.timeToRetry      = timeToRetry;
            this.maxRetries       = maxRetries;
            this.downloadBuilder  = downloadBuilder ?? throw new ArgumentNullException("Download buider can't be null!");
        }
Example #4
0
        public ResumingDownload(Uri url, int bufferSize, long?offset, long?maxReadBytes, int timeForHeartbeat, int timeToRetry, int?maxRetries, ISDBuilder downloadBuilder)
            : base(url, bufferSize, offset, maxReadBytes, null, null)
        {
            if (timeForHeartbeat <= 0)
            {
                throw new ArgumentException("timeForHeartbeat <= 0");
            }

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

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

            this.timeForHeartbeat = timeForHeartbeat;
            this.timeToRetry      = timeToRetry;
            this.maxRetries       = maxRetries;
            this.downloadBuilder  = downloadBuilder;
        }