• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IWebProxy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetNewShortUrl

        public string GetNewShortUrl(string sourceUrl, IWebProxy webProxy)
        {
            if (sourceUrl == null)
                throw new ArgumentNullException("sourceUrl");

            // fallback will be source url
            string result = sourceUrl;
            //Added 11/3/2007 scottckoon
            //20 is the shortest a tinyURl can be (http://tinyurl.com/a)
            //so if the sourceUrl is shorter than that, don't make a request to TinyURL
            if (sourceUrl.Length > 20 && !IsShortenedUrl(sourceUrl))
            {
                // tinyurl doesn't like urls w/o protocols so we'll ensure we have at least http
                string requestUrl = string.Format(this.requestTemplate,(EnsureMinimalProtocol(sourceUrl)));
                WebRequest request = HttpWebRequest.Create(requestUrl);

                request.Proxy = webProxy;

                try
                {
                    using (Stream responseStream = request.GetResponse().GetResponseStream())
                    {
                        StreamReader reader = new StreamReader(responseStream, Encoding.ASCII);
                        result = reader.ReadToEnd();
                    }
                }
                catch
                {
                    // eat it and return original url
                }
            }
            //scottckoon - It doesn't make sense to return a TinyURL that is longer than the original.
            if (result.Length > sourceUrl.Length) { result = sourceUrl; }
            return result;
        }
开发者ID:jredville,项目名称:irwitty,代码行数:35,代码来源:UrlShorteningService.cs


示例17: GetCredentials

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

            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"));

            using (SecureString password = new SecureString())
            {
                Console.ReadSecureString(password);
                var credentials = new NetworkCredential
                {
                    UserName = username,
                    SecurePassword = password
                };
                return credentials;
            }
        }
开发者ID:Newtopian,项目名称:nuget,代码行数:26,代码来源:ConsoleCredentialProvider.cs


示例18: GetSearchResults

        public TweetCollection GetSearchResults(string searchText, IWebProxy webProxy)
        {
            TweetCollection tweets = new TweetCollection();

            string tweetscanUrl = "http://tweetscan.com/trss.php?s=" + searchText;

            HttpWebRequest request = WebRequest.Create(tweetscanUrl) as HttpWebRequest;

            // Add configured web proxy
            request.Proxy = webProxy;

            //try
            //{
                // Get the Web Response
                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    // Get the response stream
                    StreamReader reader = new StreamReader(response.GetResponseStream());

                    // Load the response data into a XmlDocument
                    XmlDocument doc = new XmlDocument();
                    doc.Load(reader);

                    // Get statuses with XPath
                    XmlNodeList nodes = doc.SelectNodes("/rss/channel/item");

                    foreach (XmlNode node in nodes)
                    {
                        Tweet tweet = new Tweet();
                        tweet.Id = double.Parse(node.SelectSingleNode("tweetid").InnerText);
                        tweet.Text = HttpUtility.HtmlDecode(node.SelectSingleNode("text").InnerText);

                        string dateString = node.SelectSingleNode("pubdate").InnerText;
                        if (!string.IsNullOrEmpty(dateString))
                        {
                            tweet.DateCreated = DateTime.Parse(dateString);
                        }

                        User user = new User();

                        user.Name = node.SelectSingleNode("username").InnerText;
                        user.ScreenName = node.SelectSingleNode("screenname").InnerText;
                        user.ImageUrl = node.SelectSingleNode("image").InnerText;

                        tweet.User = user;

                        tweets.Add(tweet);
                    }

                    tweets.SaveToDisk();
                }
            //}
            //catch {
            ////TODO: not sure what kind of errors are thrown by tweetcan
            //    // eat it.
            //}

            return tweets;
        }
开发者ID:jredville,项目名称:irwitty,代码行数:59,代码来源:TweetScanHelper.cs


示例19: Add

 public void Add(IWebProxy proxy)
 {
     var webProxy = proxy as WebProxy;
     if (webProxy != null)
     {
         _cache.TryAdd(webProxy.Address, webProxy);
     }
 }
开发者ID:304NotModified,项目名称:NuGetPackageExplorer-1,代码行数:8,代码来源:ProxyCache.cs


示例20: GetCredentials

		public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType, bool retrying)
		{
			var cp = MonoDevelop.Core.WebRequestHelper.CredentialProvider;
			if (cp == null)
				return null;

			return cp.GetCredentials (uri, proxy, (MonoDevelop.Core.Web.CredentialType)credentialType, retrying);
		}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:8,代码来源:MonoDevelopCredentialProvider.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IWebResponseData类代码示例发布时间:2022-05-24
下一篇:
C# IWebHelper类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap