/// <summary> /// Initializes a new instance of the Downloader class. /// </summary> /// <param name="maxConcurrentDownloads">The maximum number of concurrent downloads allowed.</param> /// <param name="cacheProfile">The <see cref="CacheProfile"/> to use.</param> public Downloader(int maxConcurrentDownloads, CacheProfile cacheProfile) { this.MaxConcurrentDownloads = maxConcurrentDownloads < 0 ? 0 : maxConcurrentDownloads; this.cache = Downloader.CreateCache(cacheProfile); this.processing = new List<DownloadTask>(); this.queued = new List<DownloadTask>(); }
/// <summary> /// Initializes a new instance of the Downloader class. /// </summary> /// <param name="cacheProfile">The <see cref="CacheProfile"/> to use.</param> public Downloader(CacheProfile cacheProfile) : this(4, cacheProfile) { }
private static ICache CreateCache(CacheProfile cacheProfile) { cacheProfile = cacheProfile ?? CacheProfile.Memory(); switch (cacheProfile.CacheType) { case CacheType.Disk: return new DiskCache(cacheProfile.LocalPath, cacheProfile.MaximumSize); case CacheType.Memory: return new MemoryCache(cacheProfile.MaximumSize); default: throw new NotImplementedException(); } }