public Task <IDownloader> CreateDownloaderAsync(string agentId,
                                                        AllotDownloaderMessage allotDownloaderMessage)
        {
            IDownloader downloader = null;

            switch (allotDownloaderMessage.Type)
            {
            case DownloaderType.Empty:
            {
                downloader = new EmptyDownloader
                {
                    AgentId = agentId,
                    Logger  = _loggerFactory.CreateLogger <ExceptionDownloader>()
                };
                break;
            }

            case DownloaderType.Test:
            {
                downloader = new TestDownloader
                {
                    AgentId = agentId,
                    Logger  = _loggerFactory.CreateLogger <ExceptionDownloader>()
                };
                break;
            }

            case DownloaderType.Exception:
            {
                downloader = new ExceptionDownloader
                {
                    AgentId = agentId,
                    Logger  = _loggerFactory.CreateLogger <ExceptionDownloader>()
                };
                break;
            }

            case DownloaderType.WebDriver:
            {
                throw new NotImplementedException();
            }

            case DownloaderType.HttpClient:
            {
                var httpClient = new HttpClientDownloader
                {
                    AgentId           = agentId,
                    UseProxy          = allotDownloaderMessage.UseProxy,
                    AllowAutoRedirect = allotDownloaderMessage.AllowAutoRedirect,
                    Timeout           = allotDownloaderMessage.Timeout,
                    DecodeHtml        = allotDownloaderMessage.DecodeHtml,
                    UseCookies        = allotDownloaderMessage.UseCookies,
                    Logger            = _loggerFactory.CreateLogger <HttpClientDownloader>(),
                    HttpProxyPool     = string.IsNullOrWhiteSpace(_options.ProxySupplyUrl)
                            ? null
                            : new HttpProxyPool(new HttpRowTextProxySupplier(_options.ProxySupplyUrl)),
                    RetryTime = allotDownloaderMessage.RetryTimes
                };
                httpClient.AddCookies(allotDownloaderMessage.Cookies);
                downloader = httpClient;
                break;
            }
            }

            return(Task.FromResult(downloader));
        }
        public Task <DownloaderEntry> CreateDownloaderEntryAsync(AllotDownloaderMessage allotDownloaderMessage)
        {
            DownloaderEntry downloaderEntry = null;

            // TODO: 添加其它下载器的分配方法
            switch (allotDownloaderMessage.Type)
            {
            case DownloaderType.Empty:
            {
                downloaderEntry = new DownloaderEntry
                {
                    LastUsedTime = DateTime.Now,
                    Downloader   = new EmptyDownloader()
                };
                break;
            }

            case DownloaderType.Test:
            {
                downloaderEntry = new DownloaderEntry
                {
                    LastUsedTime = DateTime.Now,
                    Downloader   = new TestDownloader()
                };
                break;
            }

            case DownloaderType.Exception:
            {
                downloaderEntry = new DownloaderEntry
                {
                    LastUsedTime = DateTime.Now,
                    Downloader   = new ExceptionDownloader()
                };
                break;
            }

            case DownloaderType.WebDriver:
            {
                throw new NotImplementedException();
            }

            case DownloaderType.HttpClient:
            {
                var httpClient = new HttpClientDownloader
                {
                    UseProxy          = allotDownloaderMessage.UseProxy,
                    AllowAutoRedirect = allotDownloaderMessage.AllowAutoRedirect,
                    Timeout           = allotDownloaderMessage.Timeout,
                    DecodeHtml        = allotDownloaderMessage.DecodeHtml,
                    UseCookies        = allotDownloaderMessage.UseCookies
                };
                httpClient.AddCookies(allotDownloaderMessage.Cookies);
                downloaderEntry = new DownloaderEntry
                {
                    LastUsedTime = DateTime.Now,
                    Downloader   = httpClient
                };

                break;
            }
            }

            return(Task.FromResult(downloaderEntry));
        }