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


C# WebParameterCollection类代码示例

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


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


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