本文整理汇总了C#中IWebClient.UploadValues方法的典型用法代码示例。如果您正苦于以下问题:C# IWebClient.UploadValues方法的具体用法?C# IWebClient.UploadValues怎么用?C# IWebClient.UploadValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWebClient
的用法示例。
在下文中一共展示了IWebClient.UploadValues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RequestIterationCount
private static int RequestIterationCount(string username, IWebClient webClient)
{
Func<Exception, Exception> invalidInt = (e) => new LoginException(LoginException.FailureReason.InvalidResponse,
"Iteration count is invalid",
e);
try
{
// LastPass server is supposed to return paint text int, nothing fancy.
return int.Parse(webClient.UploadValues("https://lastpass.com/iterations.php",
new NameValueCollection {{"email", username}}).ToUtf8());
}
catch (WebException e)
{
throw new LoginException(LoginException.FailureReason.WebException, "WebException occured", e);
}
catch (FormatException e)
{
throw invalidInt(e);
}
catch (OverflowException e)
{
throw invalidInt(e);
}
}
示例2: MakeRequest
private string MakeRequest(IWebClient client, string url)
{
if (method == "GET")
{
return client.DownloadString(url);
}
else
{
return client.UploadValues(method, url, GetData());
}
}
示例3: Login
private static XDocument Login(string username,
string password,
string multifactorPassword,
int keyIterationCount,
IWebClient webClient)
{
try
{
var parameters = new NameValueCollection
{
{"method", "mobile"},
{"web", "1"},
{"xml", "1"},
{"username", username},
{"hash", FetcherHelper.MakeHash(username, password, keyIterationCount)},
{"iterations", string.Format("{0}", keyIterationCount)}
};
if (multifactorPassword != null)
parameters["otp"] = multifactorPassword;
return XDocument.Parse(webClient.UploadValues("https://lastpass.com/login.php",
parameters).ToUtf8());
}
catch (WebException e)
{
throw new LoginException(LoginException.FailureReason.WebException,
"WebException occured",
e);
}
catch (XmlException e)
{
throw new LoginException(LoginException.FailureReason.InvalidResponse,
"Invalid XML in response",
e);
}
}