当前位置: 首页>>代码示例>>C#>>正文


C# IWebProxy类代码示例

本文整理汇总了C#中IWebProxy的典型用法代码示例。如果您正苦于以下问题:C# IWebProxy类的具体用法?C# IWebProxy怎么用?C# IWebProxy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IWebProxy类属于命名空间,在下文中一共展示了IWebProxy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: get_credentials_from_user

        public ICredentials get_credentials_from_user(Uri uri, IWebProxy proxy, CredentialType credentialType)
        {
            if (!_config.Information.IsInteractive)
            {
                return CredentialCache.DefaultCredentials;
            }

            string message = credentialType == CredentialType.ProxyCredentials ?
                                 "Please provide proxy credentials:" :
                                 "Please provide credentials for: {0}".format_with(uri.OriginalString);
            this.Log().Info(ChocolateyLoggers.Important, message);

            Console.Write("User name: ");
            string username = Console.ReadLine();
            Console.Write("Password: ");
            var password = Console.ReadLine();

            //todo: set this up as secure
            //using (var securePassword = new SecureString())
            //{
            //    foreach (var letter in password.to_string())
            //    {
            //        securePassword.AppendChar(letter);
            //    }

            var credentials = new NetworkCredential
                {
                    UserName = username,
                    Password = password,
                    //SecurePassword = securePassword
                };
            return credentials;
            // }
        }
开发者ID:secretGeek,项目名称:choco,代码行数:34,代码来源:ChocolateyNugetCredentialProvider.cs

示例2: ConnectAPI

 public ConnectAPI(IWebProxy proxy)
 {
     this.connectService = new ConnectService();
       this.connectService.Proxy = proxy;
       this.connectService.EnableDecompression = true;
       this.connectService.UserAgent = Constants.UserAgent;
 }
开发者ID:joserodriguezdtm,项目名称:ZANOX,代码行数:7,代码来源:ConnectAPI.cs

示例3: TokenProvider

 public TokenProvider(string clientId, string clientSecret, IWebProxy webProxy = null, BoxManagerOptions options = BoxManagerOptions.None)
 {
     _clientId = clientId;
     _clientSecret = clientSecret;
     _requestHelper = new RequestHelper();
     _restClient = new BoxRestClient(null, webProxy, options);
 }
开发者ID:reckcn,项目名称:box-csharp-sdk-v2,代码行数:7,代码来源:TokenProvider.cs

示例4: Create

 //
 // Create - creates internal WebProxy that stores proxy info
 //  
 protected override void Create(Object obj)
 {
     if (obj == null)
         m_IWebProxy = new WebProxy();
     else
         m_IWebProxy = ((DefaultProxyHandlerWrapper)obj).WebProxy;
 }
开发者ID:ArildF,项目名称:masters,代码行数:10,代码来源:defaultproxyhandler.cs

示例5: ConvertToWebProxy

        //IWebProxy does not give access to the underlying WebProxy it returns type WebProxyWrapper
        //the underlying webproxy is needed in order to use the proxy address, the following uses reflecion to cast to WebProxy
        static WebProxy ConvertToWebProxy(IWebProxy proxyWrapper)
        {
            PropertyInfo propertyInfo = proxyWrapper.GetType().GetProperty("WebProxy", BindingFlags.NonPublic | BindingFlags.Instance);
            WebProxy wProxy = (WebProxy)propertyInfo.GetValue(proxyWrapper, null);

            return wProxy;
        }
开发者ID:umabiel,项目名称:WsdlUI,代码行数:9,代码来源:ProxyWrapper.cs

示例6: Authorize

 /// <summary>
 ///     Generates the authorize URI.
 ///     Then call GetTokens(string) after get the pin code.
 /// </summary>
 /// <returns>
 ///     The authorize URI.
 /// </returns>
 /// <param name="consumerKey">
 ///     Consumer key.
 /// </param>
 /// <param name="consumerSecret">
 ///     Consumer secret.
 /// </param>
 /// <param name="oauthCallback">
 ///     <para>For OAuth 1.0a compliance this parameter is required. The value you specify here will be used as the URL a user is redirected to should they approve your application's access to their account. Set this to oob for out-of-band pin mode. This is also how you specify custom callbacks for use in desktop/mobile applications.</para>
 ///     <para>Always send an oauth_callback on this step, regardless of a pre-registered callback.</para>
 /// </param>
 /// <param name="proxy">
 ///     Proxy information for the request.
 /// </param>
 public static OAuthSession Authorize(string consumerKey, string consumerSecret, string oauthCallback = "oob", IWebProxy proxy = null)
 {
     // Note: Twitter says,
     // "If you're using HTTP-header based OAuth, you shouldn't include oauth_* parameters in the POST body or querystring."
     var prm = new Dictionary<string,object>();
     if (!string.IsNullOrEmpty(oauthCallback))
         prm.Add("oauth_callback", oauthCallback);
     var header = Tokens.Create(consumerKey, consumerSecret, null, null)
         .CreateAuthorizationHeader(MethodType.Get, RequestTokenUrl, prm);
     var dic = from x in Request.HttpGet(RequestTokenUrl, prm, header, "CoreTweet", proxy).Use()
               from y in new StreamReader(x).Use()
               select y.ReadToEnd()
                       .Split('&')
                       .Where(z => z.Contains('='))
                       .Select(z => z.Split('='))
                       .ToDictionary(z => z[0], z => z[1]);
     return new OAuthSession()
     {
         RequestToken = dic["oauth_token"],
         RequestTokenSecret = dic["oauth_token_secret"],
         ConsumerKey = consumerKey,
         ConsumerSecret = consumerSecret,
         Proxy = proxy
     };
 }
开发者ID:rhenium,项目名称:CoreTweet,代码行数:45,代码来源:OAuth.cs

示例7: FrmProxyAuth

        public FrmProxyAuth(FrmMain frmMain, IWebProxy proxy)
        {
            _frmMain = frmMain;
            _proxy = proxy;

            InitializeComponent();
        }
开发者ID:HVPA,项目名称:VariantExporter,代码行数:7,代码来源:FrmProxyAuth.cs

示例8: BoxManager

 private BoxManager(IRequestAuthenticator requestAuthenticator, IWebProxy proxy, BoxManagerOptions options, string onBehalfOf = null)
     : this()
 {
     requestAuthenticator.SetOnBehalfOf(onBehalfOf);
     _restClient = new BoxRestClient(requestAuthenticator, proxy, options);
     _uploadClient = new BoxUploadClient(requestAuthenticator, proxy, options);
 }
开发者ID:sivaraja07,项目名称:box-csharp-sdk-v2,代码行数:7,代码来源:BoxManager.cs

示例9: Scrap

        /// <summary>
        /// Requests the Correios' website for the given CEP's address, scraps the HTML and returns it.
        /// </summary>
        /// <param name="cep">CEP of the address</param>
        /// <param name="proxy">Proxy to use for the request</param>
        /// <returns>The scraped address or null if no address was found for the given CEP</returns>
        /// <exception cref="ArgumentNullException">If the given proxy is null</exception>
        /// <exception cref="ScrapException">If an unexpected HTML if found</exception>
        public static Endereco Scrap(string cep, IWebProxy proxy)
        {
            if (proxy == null)
                throw new ArgumentNullException("proxy");

            return Parse(Request(cep, proxy));
        }
开发者ID:tallesl,项目名称:net-Cep,代码行数:15,代码来源:Scrap.cs

示例10: PttRequestFactory

 /// <summary>
 /// new, proxy and cookie passed explicitly
 /// </summary>
 /// <param name="proxy"></param>
 /// <param name="cookieContainer"></param>
 public PttRequestFactory(IWebProxy proxy, CookieContainer cookieContainer = null)
 {
     _proxy = proxy;
     _cookieContainer = cookieContainer ?? new CookieContainer();
     _viewStateValue = "";
     _eventValidationValue = "";
 }
开发者ID:yukseljunk,项目名称:wps,代码行数:12,代码来源:PttRequestFactory.cs

示例11: HttpRequest

 public HttpRequest(string requestUrl, IWebProxy webProxy)
 {
     AllowAutoRedirect = true;
     ContentType = null;
     this.requestUrl = requestUrl;
     Proxy = webProxy;
 }
开发者ID:preguntoncojonero,项目名称:mylifevn,代码行数:7,代码来源:HttpRequest.cs

示例12: Config

 public Config(string userName,
     string password,
     string outDir,
     bool downloadAll,
     Document.DownloadType[] docExpType,
     Document.DownloadType[] sprdExpType,
     Document.DownloadType[] presExpType,
     Document.DownloadType[] drawExpType,
     IWebProxy webproxy,
     bool bypassHttpsChecks,
     bool debugMode,
     int? dateDiff,
     bool appsMode,
     string appsDomain,
     string appsOAuthSecret,
     bool appsOnlyOAuth)
 {
     this.userName = userName;
     this.password = password;
     this.outDir = outDir;
     this.downloadAll = downloadAll;
     this.docExpType = docExpType;
     this.sprdExpType = sprdExpType;
     this.presExpType = presExpType;
     this.drawExpType = drawExpType;
     this.iwebproxy = webproxy;
     this.bypassHttpsChecks = bypassHttpsChecks;
     this.debugMode = debugMode;
     this.dateDiff = dateDiff;
     this.appsMode = appsMode;
     this.appsDomain = appsDomain;
     this.appsOAuthSecret = appsOAuthSecret;
     this.appsOnlyOAuth = appsOnlyOAuth;
 }
开发者ID:superhafnium,项目名称:gdocbackup,代码行数:34,代码来源:Config.cs

示例13: PublisherAPI

 public PublisherAPI(IWebProxy proxy)
 {
     this.publisherService = new PublisherService();
       this.publisherService.Proxy = proxy;
       this.publisherService.EnableDecompression = true;
       this.publisherService.UserAgent = Constants.UserAgent;
 }
开发者ID:joserodriguezdtm,项目名称:ZANOX,代码行数:7,代码来源:PublisherAPI.cs

示例14: GetCredentials

        public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType, bool retrying)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            if (LaunchedFromVS())
            {
                throw new InvalidOperationException(LocalizedResourceManager.GetString("Error_CannotPromptForCedentials"));
            }

            string message = credentialType == CredentialType.ProxyCredentials ?
                    LocalizedResourceManager.GetString("Credentials_ProxyCredentials") :
                    LocalizedResourceManager.GetString("Credentials_RequestCredentials");
            Console.WriteLine(message, uri.OriginalString);
            Console.Write(LocalizedResourceManager.GetString("Credentials_UserName"));
            string username = Console.ReadLine();
            Console.Write(LocalizedResourceManager.GetString("Credentials_Password"));
            SecureString password = ReadLineAsSecureString();
            var credentials = new NetworkCredential
            {
                UserName = username,
                SecurePassword = password
            };

            return credentials;
        }
开发者ID:themotleyfool,项目名称:NuGet,代码行数:28,代码来源:ConsoleCredentialProvider.cs

示例15: GetCredentials

        public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType , bool retrying)
        {
            if (Credentials.ContainsKey(uri))
                return Credentials[uri];

            return provider.GetCredentials(uri, proxy, credentialType, retrying);
        }
开发者ID:n3rd,项目名称:SymbolSource.Community,代码行数:7,代码来源:TestHelper.cs


注:本文中的IWebProxy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。