本文整理汇总了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;
// }
}
示例2: ConnectAPI
public ConnectAPI(IWebProxy proxy)
{
this.connectService = new ConnectService();
this.connectService.Proxy = proxy;
this.connectService.EnableDecompression = true;
this.connectService.UserAgent = Constants.UserAgent;
}
示例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);
}
示例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;
}
示例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;
}
示例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
};
}
示例7: FrmProxyAuth
public FrmProxyAuth(FrmMain frmMain, IWebProxy proxy)
{
_frmMain = frmMain;
_proxy = proxy;
InitializeComponent();
}
示例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);
}
示例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));
}
示例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 = "";
}
示例11: HttpRequest
public HttpRequest(string requestUrl, IWebProxy webProxy)
{
AllowAutoRedirect = true;
ContentType = null;
this.requestUrl = requestUrl;
Proxy = webProxy;
}
示例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;
}
示例13: PublisherAPI
public PublisherAPI(IWebProxy proxy)
{
this.publisherService = new PublisherService();
this.publisherService.Proxy = proxy;
this.publisherService.EnableDecompression = true;
this.publisherService.UserAgent = Constants.UserAgent;
}
示例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;
}
示例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);
}