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

C# WebParameterCollection类代码示例

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

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



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

示例1: BuildRequestTokenInfo

        /// <summary>
        /// Generates a <see cref="OAuthWebQueryInfo"/> instance to pass to an
        /// <see cref="OAuthWebQuery" /> for the purpose of requesting an
        /// unauthorized request token.
        /// </summary>
        /// <param name="method">The HTTP method for the intended request</param>
        /// <param name="parameters">Any existing, non-OAuth query parameters desired in the request</param>
        /// <seealso cref="http://oauth.net/core/1.0#anchor9"/>
        /// <returns></returns>
        public OAuthWebQueryInfo BuildRequestTokenInfo(WebMethod method, WebParameterCollection parameters)
        {
            ValidateTokenRequestState();

            if (parameters == null)
            {
                parameters = new WebParameterCollection();
            }

            var timestamp = OAuthTools.GetTimestamp();
            var nonce = OAuthTools.GetNonce();

            AddAuthParameters(parameters, timestamp, nonce);

            var signatureBase = OAuthTools.ConcatenateRequestElements(method, RequestTokenUrl, parameters);
            var signature = OAuthTools.GetSignature(SignatureMethod, signatureBase, ConsumerSecret);

            var info = new OAuthWebQueryInfo
                           {
                               WebMethod = method,
                               ParameterHandling = ParameterHandling,
                               ConsumerKey = ConsumerKey,
                               SignatureMethod = SignatureMethod.ToRequestValue(),
                               Signature = signature,
                               Timestamp = timestamp,
                               Nonce = nonce,
                               Version = OAUTH_VERSION,
                               Callback = OAuthTools.UrlEncode(CallbackUrl ?? ""),
                               UserAgent = "TweetSharp",
                               TokenSecret = TokenSecret,
                               ConsumerSecret = ConsumerSecret
                           };

            return info;
        }
开发者ID:apanda,项目名称:TweetSharpForWinMo,代码行数:44,代码来源:OAuthWorkflow.Methods.cs


示例2: GetSignatureAuthorizationHeader

        private string GetSignatureAuthorizationHeader(WebParameterCollection parameters)
        {
            var signature = GetNewSignature(parameters);

            parameters.Add("oauth_signature", signature);

            return WriteAuthorizationHeader(parameters);
        }
开发者ID:modulexcite,项目名称:graveyard,代码行数:8,代码来源:OAuthRequest.cs


示例3: WebQueryClient

 public WebQueryClient(IDictionary<string, string> headers, WebParameterCollection parameters, string userAgent,
                       bool useTransparentProxy)
 {
     _headers = headers;
     Parameters = parameters;
     UserAgent = userAgent;
     UseTransparentProxy = useTransparentProxy;
 }
开发者ID:apanda,项目名称:TweetSharpForWinMo,代码行数:8,代码来源:WebQueryClient.cs


示例4: WebQueryClient

 public WebQueryClient(IDictionary<string, string> headers, WebParameterCollection parameters, string userAgent,
                       string method)
 {
     _headers = headers;
     Parameters = parameters;
     UserAgent = userAgent;
     Method = method;
 }
开发者ID:apanda,项目名称:TweetSharpForWinMo,代码行数:8,代码来源:WebQueryClient.cs


示例5: OAuthWebQueryClient

 public OAuthWebQueryClient(IDictionary<string, string> headers, WebParameterCollection parameters,
                            OAuthParameterHandling parameterHandling, string userAgent, string method)
 {
     _headers = headers;
     Parameters = parameters;
     ParameterHandling = parameterHandling;
     UserAgent = userAgent;
     Method = method;
 }
开发者ID:apanda,项目名称:TweetSharpForWinMo,代码行数:9,代码来源:OAuthWebQueryClient.cs


示例6: ConcatenateRequestElements

        /// <summary>
        /// Creates a request elements concatentation value to send with a request. 
        /// This is also known as the signature base.
        /// </summary>
        /// <seealso href="http://oauth.net/core/1.0#rfc.section.9.1.3"/>
        /// <seealso href="http://oauth.net/core/1.0#sig_base_example"/>
        /// <param name="method">The request's HTTP method type</param>
        /// <param name="url">The request URL</param>
        /// <param name="parameters">The request's parameters</param>
        /// <returns>A signature base string</returns>
        public static string ConcatenateRequestElements(string method, string url, WebParameterCollection parameters)
        {
            var sb = new StringBuilder();

            // Separating &'s are not URL encoded
            var requestMethod = string.Concat(method.ToUpper(), "&");
            var requestUrl = string.Concat(UrlEncodeRelaxed(ConstructRequestUrl(new Uri(url))), "&");
            var requestParameters = UrlEncodeRelaxed(NormalizeRequestParameters(parameters));

            sb.Append(requestMethod);
            sb.Append(requestUrl);
            sb.Append(requestParameters);

            return sb.ToString();
        }
开发者ID:tiagodeliberali,项目名称:OAuthClient,代码行数:25,代码来源:OAuthTools.cs


示例7: GetAuthorizationHeader

 public string GetAuthorizationHeader(WebParameterCollection parameters)
 {
     switch (Type)
     {
         case OAuthRequestType.RequestToken:
             ValidateRequestState();
             return GetSignatureAuthorizationHeader(parameters);
         case OAuthRequestType.AccessToken:
             ValidateAccessRequestState();
             return GetSignatureAuthorizationHeader(parameters);
         case OAuthRequestType.ProtectedResource:
             ValidateProtectedResourceState();
             return GetSignatureAuthorizationHeader(parameters);
         case OAuthRequestType.ClientAuthentication:
             ValidateClientAuthAccessRequestState();
             return GetClientSignatureAuthorizationHeader(parameters);
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
开发者ID:modulexcite,项目名称:graveyard,代码行数:20,代码来源:OAuthRequest.cs


示例8: GetAuthorizationHeader

        public string GetAuthorizationHeader(NameValueCollection parameters)
        {
            var collection = new WebParameterCollection(parameters);

            return GetAuthorizationHeader(collection);
        }
开发者ID:RabidDog,项目名称:oauth,代码行数:6,代码来源:OAuthRequest.cs


示例9: NormalizeRequestParameters

 /// <summary>
 /// Sorts a collection of key-value pairs by name, and then value if equal,
 /// concatenating them into a single string. This string should be encoded
 /// prior to, or after normalization is run.
 /// </summary>
 /// <seealso cref="http://oauth.net/core/1.0#rfc.section.9.1.1"/>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public static string NormalizeRequestParameters(WebParameterCollection parameters)
 {
     var copy = SortParametersExcludingSignature(parameters);
     foreach (var param in copy)
     {
         param.Value = UrlEncodeParameterString(param.Value);
     }
     var concatenated = copy.Concatenate("=", "&");
     return concatenated;
 }
开发者ID:apanda,项目名称:TweetSharpForWinMo,代码行数:18,代码来源:OAuthTools.cs


示例10: CreateWebQueryClient

        private static IWebQueryClient CreateWebQueryClient(IDictionary<string, string> headers,
                                                            WebParameterCollection parameters, string userAgent,
                                                            bool mockClient, IEnumerable<IModel> graph,
                                                            bool useTransparentProxy, string method)
        {
            return
#if !SILVERLIGHT
                mockClient
                ? (IWebQueryClient) new WebQueryClientMock(graph) :
                new WebQueryClient(headers, parameters, userAgent, method);
#else
                new WebQueryClient(headers, parameters, userAgent, useTransparentProxy);
#endif
        }
开发者ID:apanda,项目名称:TweetSharpForWinMo,代码行数:14,代码来源:WebQueryBase.cs


示例11: AddAuthParameters

        private void AddAuthParameters(ICollection<WebParameter> parameters, string timestamp, string nonce)
        {
            var authParameters = new WebParameterCollection
                                     {
                                         new WebParameter("oauth_consumer_key", ConsumerKey),
                                         new WebParameter("oauth_nonce", nonce),
                                         new WebParameter("oauth_signature_method", SignatureMethod.ToRequestValue()),
                                         new WebParameter("oauth_timestamp", timestamp),
                                         new WebParameter("oauth_version", OAUTH_VERSION)
                                     };

            if (!Token.IsNullOrBlank())
            {
                authParameters.Add(new WebParameter("oauth_token", Token));
            }

            if (!CallbackUrl.IsNullOrBlank())
            {
                authParameters.Add(new WebParameter("oauth_callback", CallbackUrl));
            }

            if (!Verifier.IsNullOrBlank())
            {
                authParameters.Add(new WebParameter("oauth_verifier", Verifier));
            }

            foreach (var authParameter in authParameters)
            {
                parameters.Add(authParameter);
            }
        }
开发者ID:apanda,项目名称:TweetSharpForWinMo,代码行数:31,代码来源:OAuthWorkflow.Methods.cs


示例12: getCar2GoAccounts

        private void getCar2GoAccounts(string token, string token_secret, DownloadStringCompletedEventHandler requestCallback)
        {
            var car2GoRequestEndpoint = "https://www.car2go.com/api/v2.1/accounts";

            var parameters = new WebParameterCollection();
            parameters.Add("oauth_callback", "oob");
            parameters.Add("oauth_signature_method", "HMAC-SHA1");
            parameters.Add("oauth_token", token);
            parameters.Add("oauth_version", "1.0");
            parameters.Add("oauth_consumer_key", FreeCarsCredentials.Car2Go.ConsumerKey);
            parameters.Add("oauth_timestamp", OAuthTools.GetTimestamp());
            parameters.Add("oauth_nonce", OAuthTools.GetNonce());
            parameters.Add("format", "json");
            parameters.Add("loc", Car2Go.City);
            //parameters.Add("test", "1");
            var signatureBase = OAuthTools.ConcatenateRequestElements("GET", car2GoRequestEndpoint, parameters);
            var signature = OAuthTools.GetSignature(OAuthSignatureMethod.HmacSha1, OAuthSignatureTreatment.Escaped, signatureBase, FreeCarsCredentials.Car2Go.SharedSecred, token_secret);

            var requestParameters = OAuthTools.NormalizeRequestParameters(parameters);
            var requestUrl = new Uri(car2GoRequestEndpoint + "?" + requestParameters + "&oauth_signature=" + signature, UriKind.Absolute);

            var webClient = new WebClient();
            webClient.DownloadStringCompleted += requestCallback;

            webClient.DownloadStringAsync(requestUrl);
        }
开发者ID:hanseartic,项目名称:FreeCars,代码行数:26,代码来源:SettingsPage.xaml.cs


示例13: WriteAuthorizationQuery

        private static string WriteAuthorizationQuery(WebParameterCollection parameters)
        {
            var sb = new StringBuilder();

            parameters.Sort((l, r) => l.Name.CompareTo(r.Name));

            var count = 0;

            foreach (var parameter in parameters.Where(parameter =>
                                                       !IsNullOrBlank(parameter.Name) &&
                                                       !IsNullOrBlank(parameter.Value) &&
                                                       parameter.Name.StartsWith("oauth_")))
            {
                count++;
                var format = count < parameters.Count ? "{0}={1}&" : "{0}={1}";
                sb.AppendFormat(format, parameter.Name, parameter.Value);
            }

            var authorization = sb.ToString();
            return authorization;
        }
开发者ID:RabidDog,项目名称:oauth,代码行数:21,代码来源:OAuthRequest.cs


示例14: AddXAuthParameters

        private void AddXAuthParameters(ICollection<WebParameter> parameters, string timestamp, string nonce)
        {
            var authParameters = new WebParameterCollection
                                     {
                                         new WebParameter("x_auth_username", ClientUsername),
                                         new WebParameter("x_auth_password", ClientPassword),
                                         new WebParameter("x_auth_mode", "client_auth"),
                                         new WebParameter("oauth_consumer_key", ConsumerKey),
                                         new WebParameter("oauth_signature_method", ToRequestValue(SignatureMethod)),
                                         new WebParameter("oauth_timestamp", timestamp),
                                         new WebParameter("oauth_nonce", nonce),
                                         new WebParameter("oauth_version", Version ?? "1.0")
                                     };

            foreach (var authParameter in authParameters)
            {
                parameters.Add(authParameter);
            }
        }
开发者ID:RabidDog,项目名称:oauth,代码行数:19,代码来源:OAuthRequest.cs


示例15: SortParametersExcludingSignature

        /// <summary>
        /// Sorts a <see cref="WebParameterCollection"/> by name, and then value if equal.
        /// </summary>
        /// <param name="parameters">A collection of parameters to sort</param>
        /// <returns>A sorted parameter collection</returns>
        public static WebParameterCollection SortParametersExcludingSignature(WebParameterCollection parameters)
        {
            var copy = new WebParameterCollection(parameters);
            var exclusions = copy.Where(n => EqualsIgnoreCase(n.Name, "oauth_signature"));

            copy.RemoveAll(exclusions);

            foreach(var parameter in copy)
            {
                parameter.Value = UrlEncodeStrict(parameter.Value);
            }

            copy.Sort((x, y) => x.Name.Equals(y.Name) ? x.Value.CompareTo(y.Value) : x.Name.CompareTo(y.Name));
            return copy;
        }
开发者ID:tiagodeliberali,项目名称:OAuthClient,代码行数:20,代码来源:OAuthTools.cs


示例16: NormalizeRequestParameters

 /// <summary>
 /// Sorts a collection of key-value pairs by name, and then value if equal,
 /// concatenating them into a single string. This string should be encoded
 /// prior to, or after normalization is run.
 /// </summary>
 /// <seealso href="http://oauth.net/core/1.0#rfc.section.9.1.1"/>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public static string NormalizeRequestParameters(WebParameterCollection parameters)
 {
     var copy = SortParametersExcludingSignature(parameters);
     var concatenated = Concatenate(copy, "=", "&");
     return concatenated;
 }
开发者ID:tiagodeliberali,项目名称:OAuthClient,代码行数:14,代码来源:OAuthTools.cs


示例17: SortParametersExcludingSignature

        /// <summary>
        /// Sorts a <see cref="WebParameterCollection"/> by name, and then value if equal.
        /// </summary>
        /// <param name="parameters">A collection of parameters to sort</param>
        /// <returns>A sorted parameter collection</returns>
        public static WebParameterCollection SortParametersExcludingSignature(WebParameterCollection parameters)
        {
            var copy = new WebParameterCollection(parameters);
            var exclusions = copy.Where(n => n.Name.EqualsIgnoreCase("oauth_signature"));

            copy.RemoveAll(exclusions);
            copy.ForEach(p => p.Value = UrlEncode(p.Value)); // values are effectively double-encoded
            copy.Sort((x, y) => x.Name.Equals(y.Name) ? x.Value.CompareTo(y.Value) : x.Name.CompareTo(y.Name));
            return copy;
        }
开发者ID:apanda,项目名称:TweetSharpForWinMo,代码行数:15,代码来源:OAuthTools.cs


示例18: WriteAuthorizationHeader

        private string WriteAuthorizationHeader(WebParameterCollection parameters)
        {
            var sb = new StringBuilder("OAuth ");

            if (!IsNullOrBlank(Realm))
            {
                sb.AppendFormat("realm=\"{0}\",", OAuthTools.UrlEncodeRelaxed(Realm));
            }

            parameters.Sort((l, r) => l.Name.CompareTo(r.Name));

            foreach (var parameter in parameters.Where(parameter =>
                                                       !IsNullOrBlank(parameter.Name) &&
                                                       !IsNullOrBlank(parameter.Value) &&
                                                       (parameter.Name.StartsWith("oauth_") || parameter.Name.StartsWith("x_auth_"))))
            {
                sb.AppendFormat("{0}=\"{1}\",", parameter.Name, parameter.Value);
            }

            sb.Remove(sb.Length - 1, 1);

            var authorization = sb.ToString();
            return authorization;
        }
开发者ID:FoxCubGames,项目名称:oauth-apn,代码行数:24,代码来源:OAuthRequest.cs


示例19: GetNewSignatureXAuth

        private string GetNewSignatureXAuth(WebParameterCollection parameters)
        {
            var timestamp = OAuthTools.GetTimestamp();

            var nonce = OAuthTools.GetNonce();

            AddXAuthParameters(parameters, timestamp, nonce);

            var signatureBase = OAuthTools.ConcatenateRequestElements(Method.ToUpperInvariant(), RequestUrl, parameters);

            var signature = OAuthTools.GetSignature(SignatureMethod, SignatureTreatment, signatureBase, ConsumerSecret);

            return signature;
        }
开发者ID:RabidDog,项目名称:oauth,代码行数:14,代码来源:OAuthRequest.cs


示例20: GetAuthorizationQuery

        public string GetAuthorizationQuery()
        {
            var collection = new WebParameterCollection(0);

            return GetAuthorizationQuery(collection);
        }
开发者ID:RabidDog,项目名称:oauth,代码行数:6,代码来源:OAuthRequest.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# WebRequest类代码示例发布时间:2022-05-24
下一篇:
C# WebPage类代码示例发布时间: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