Пример #1
0
 public DownloadService(DownloadConfiguration options) : this()
 {
     if (options != null)
     {
         Package.Options = options.Clone() as DownloadConfiguration;
     }
 }
Пример #2
0
 public DownloadService(DownloadConfiguration options) : this()
 {
     if (options != null)
     {
         Options = options;
     }
 }
Пример #3
0
 public Download(
     DownloadPackage package,
     DownloadConfiguration configuration)
 {
     downloadService = new DownloadService(configuration);
     Package         = package;
     Status          = DownloadStatus.Stopped;
 }
Пример #4
0
        public DownloadService(DownloadConfiguration options = null)
        {
            Package = new DownloadPackage {
                Options = options ?? new DownloadConfiguration()
            };

            ServicePointManager.SecurityProtocol =
                SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
            ServicePointManager.Expect100Continue       = false; // accept the request for POST, PUT and PATCH verbs
            ServicePointManager.DefaultConnectionLimit  = 1000;
            ServicePointManager.MaxServicePointIdleTime = 1000;
        }
Пример #5
0
        public DownloadService(DownloadConfiguration options = null)
        {
            Package = new DownloadPackage()
            {
                Options = options ?? new DownloadConfiguration()
            };

            ServicePointManager.Expect100Continue       = false; // accept the request for POST, PUT and PATCH verbs
            ServicePointManager.DefaultConnectionLimit  = 100;
            ServicePointManager.MaxServicePointIdleTime = 1000;

            Cts = new CancellationTokenSource();
        }
Пример #6
0
        public Download(
            string url,
            string path,
            string filename,
            DownloadConfiguration configuration)
        {
            downloadService =
                configuration is not null ?
                new DownloadService(configuration) :
                new DownloadService();

            Url      = url;
            Folder   = path;
            Filename = filename;
            Status   = DownloadStatus.Created;
        }
Пример #7
0
        public static string AddTask(string url, string name, string savePath = null, int threadCount = 4, int blockSize = 3)
        {
            MaxThread = threadCount;
            DownloadConfiguration configuration = new DownloadConfiguration();

            configuration.SaveDirectory = savePath ?? configuration.SaveDirectory;
            configuration.ChunkCount    = blockSize;
            configuration.TempDirectory = "C:\\temp";
            DownloadPackage package = new DownloadPackage
            {
                Options       = configuration,
                Address       = new Uri(url),
                FileName      = name,
                SaveDirectory = configuration.SaveDirectory
            };

            _downloadPackages.Add(package);
            return(package.DId);
        }
Пример #8
0
        // ReSharper disable once MemberCanBePrivate.Global
        public DownloadService()
        {
            _bandwidth = new Bandwidth();
            Options    = new DownloadConfiguration();
            Package    = new DownloadPackage();

            // This property selects the version of the Secure Sockets Layer (SSL) or
            // existing connections aren't changed.
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

            // Accept the request for POST, PUT and PATCH verbs
            ServicePointManager.Expect100Continue = false;

            // Note: Any changes to the DefaultConnectionLimit property affect both HTTP 1.0 and HTTP 1.1 connections.
            // It is not possible to separately alter the connection limit for HTTP 1.0 and HTTP 1.1 protocols.
            ServicePointManager.DefaultConnectionLimit = 1000;

            // Set the maximum idle time of a ServicePoint instance to 10 seconds.
            // After the idle time expires, the ServicePoint object is eligible for
            // garbage collection and cannot be used by the ServicePointManager object.
            ServicePointManager.MaxServicePointIdleTime = 10000;
        }
Пример #9
0
 public ChunkDownloader(Chunk chunk, DownloadConfiguration config)
 {
     Chunk         = chunk;
     Configuration = config;
 }
Пример #10
0
 public ChunkHub(DownloadConfiguration config)
 {
     _configuration = config;
 }
Пример #11
0
 public DownloadBuilder WithConfiguration(DownloadConfiguration configuration)
 {
     downloadConfiguration = configuration;
     return(this);
 }
Пример #12
0
 public static IDownload Build(DownloadPackage package, DownloadConfiguration downloadConfiguration)
 {
     return(new Download(package, downloadConfiguration));
 }
Пример #13
0
 public ChunkDownloader(Chunk chunk, DownloadConfiguration config)
 {
     Chunk         = chunk;
     Configuration = config;
     Configuration.PropertyChanged += ConfigurationPropertyChanged;
 }