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


C# IWebClient.UploadValues方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:MartonBoda,项目名称:lastpass-sharp,代码行数:25,代码来源:Fetcher.cs

示例2: MakeRequest

 private string MakeRequest(IWebClient client, string url)
 {
     if (method == "GET")
     {
         return client.DownloadString(url);
     }
     else
     {
         return client.UploadValues(method, url, GetData());
     }
 }
开发者ID:brianhartsock,项目名称:powershell-rackspaceapps,代码行数:11,代码来源:EmailApiCommand.cs

示例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);
            }
        }
开发者ID:MartonBoda,项目名称:lastpass-sharp,代码行数:37,代码来源:Fetcher.cs


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