一个webproxy代理类

using System;
using System.Net;
using log4net;

namespace Witty
{
    public static class WebProxyHelper
    {
        private static Properties.Settings AppSettings = Properties.Settings.Default;
        private static readonly ILog logger = LogManager.GetLogger("Witty.Logging");

        public static IWebProxy GetConfiguredWebProxy()
        {
            WebProxy proxy = null;
            if (AppSettings.UseProxy)
            {
                try
                {
                    proxy = new WebProxy(AppSettings.ProxyServer, AppSettings.ProxyPort);
                    proxy.Credentials = new NetworkCredential(AppSettings.ProxyUsername, AppSettings.ProxyPassword);
                }
                catch (UriFormatException ex)
                {
                    logger.Debug(ex.ToString());
                }
            }
            return proxy;
        }
    }
}
posted @ 2008-09-25 14:39  PointNet  阅读(2904)  评论(0编辑  收藏  举报