예제 #1
0
        public override async Task RunAsync()
        {
            var conf = DbConfigManager.Default.GetConfig("SqlServerTest", true);

            if (conf == null)
            {
                throw new DbConfigNotFoundException();
            }
            var proxyAgent = ProxyAgent <SqlServerProxyDbContext> .CreateInstance(conf, c => new SqlServerProxyDbContext(c));

            DefaultProxyUriLoader proxyUriLoader = new DefaultProxyUriLoader()
            {
                Days       = 360,
                Condition  = p => p.Id > 0,
                ProxyAgent = proxyAgent
            };
            DefaultWebProxyValidator webProxyValidator = new DefaultWebProxyValidator(CreateWebClient, ValidateWebProxy, new WebProxyValidatorConfig()
            {
                UseThresold         = 1,
                VerifyPauseThresold = 2
            });
            DefaultWebProxySelector proxySelector = new DefaultWebProxySelector(new Uri("http://www.baidu.com"), proxyUriLoader, webProxyValidator);

            proxySelector.Initialize();
            string rspText = await HttpConsole.GetResponseTextByProxyAsync(HomePageUri, proxySelector, GetResponseTextAsync);

            ShowLogInfo(rspText);
        }
예제 #2
0
        public override async Task RunAsync()
        {
            DefaultProxyUriLoader proxyUriLoader = new DefaultProxyUriLoader()
            {
                Days             = 360,
                DbContextFactory = () => ProxyDbContext.CreateInstance()
            };
            DefaultWebProxyValidator webProxyValidator = new DefaultWebProxyValidator(CreateWebClient, ValidateWebProxy, new WebProxyValidatorConfig()
            {
                UseThresold         = 1,
                VerifyPauseThresold = 2
            });
            DefaultWebProxySelector proxySelector = new DefaultWebProxySelector(new Uri("http://www.baidu.com"), proxyUriLoader, webProxyValidator);

            proxySelector.Initialize();
            string rspText = await HttpConsole.GetResponseTextByProxyAsync(HomePageUri, proxySelector, GetResponseTextAsync).ConfigureAwait(false);

            ShowLogInfo(rspText);
        }