상속: IModelChanged
예제 #1
0
        public ProxyForm(ProxyInfo proxyInfo)
        {
            _proxyInfo = proxyInfo;
            InitializeComponent();

            if(!string.IsNullOrEmpty(proxyInfo.Host))
            {
                txtProxy.Text = _proxyInfo.Host;
                txtPort.Text = _proxyInfo.Port.ToString();
            }
            if (_proxyInfo.Credentials != null && (!string.IsNullOrEmpty(_proxyInfo.Credentials.User)))
            {
                txtUser.Text = _proxyInfo.Credentials.User;
                txtPassword.Text = _proxyInfo.Credentials.Password;
            }
        }
예제 #2
0
 private HttpClient GetHttpClient(EndPointInfo endpoint, ProxyInfo proxy, string resource)
 {
     HttpClient result = new HttpClient();
     result.BaseAddress = endpoint.GetResourceUri(resource);
     if ((endpoint.Credentials != null) && (!String.IsNullOrEmpty(endpoint.Credentials.User)))
     {
         result.TransportSettings.Credentials = new NetworkCredential(endpoint.Credentials.User, endpoint.Credentials.Password);
     }
     if ((proxy != null) && (!String.IsNullOrEmpty(proxy.Host)))
     {
         WebProxy webProxy = new WebProxy(proxy.Host, proxy.Port);
         if ((proxy.Credentials != null) && (!String.IsNullOrEmpty(proxy.Credentials.User)))
         {
             webProxy.Credentials = new NetworkCredential(proxy.Credentials.User, proxy.Credentials.Password);
         }
         result.TransportSettings.Proxy = webProxy;
     }
     result.TransportSettings.ConnectionTimeout = new TimeSpan(0, 5, 0);
     return result;
 }