Exemplo n.º 1
0
        /// <summary>
        /// Создается, и инициируется WebClient
        /// </summary>
        /// <param name="settings">Настройки прокси</param>
        /// <returns></returns>
        private static System.Net.WebClient InitWebClient(Settings settings)
        {
            l.Debug("Создаю WebClient");
            System.Net.WebClient webClient = new TimeoutWebClient();

            // настраиваю прокси
            if (settings.useProxy)
            {
                System.Net.WebProxy webProxy = new System.Net.WebProxy();
                webProxy.Address = new Uri(settings.proxy);

                if (settings.proxyWithPassword)
                {
                    webProxy.Credentials = new System.Net.NetworkCredential(settings.proxyUser, settings.proxyPassword);
                }
                webClient.Proxy = webProxy;
            }
            return(webClient);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Создается, и инициируется WebClient
        /// </summary>
        /// <param name="settings">Настройки прокси</param>
        /// <returns></returns>
        private static System.Net.WebClient InitWebClient(Settings settings)
        {
            l.Debug("Создаю WebClient");
            System.Net.WebClient webClient = new TimeoutWebClient();

            // настраиваю прокси
            if (settings.useProxy)
            {
                System.Net.WebProxy webProxy = new System.Net.WebProxy();
                webProxy.Address = new Uri(settings.proxy);

                if (settings.proxyWithPassword)
                {
                    webProxy.Credentials = new System.Net.NetworkCredential(settings.proxyUser, settings.proxyPassword);
                }
                webClient.Proxy = webProxy;
            }
            return webClient;
        }