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


C# WebParameterCollection.Add方法代码示例

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


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

示例1: GetSignatureAuthorizationHeader

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

            parameters.Add("oauth_signature", signature);

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

示例2: GetClientSignatureAuthorizationQuery

        private string GetClientSignatureAuthorizationQuery(WebParameterCollection parameters)
        {
            var signature = GetNewSignatureXAuth(parameters);

            parameters.Add("oauth_signature", signature);

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

示例3: 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", ToRequestValue(SignatureMethod)),
                                         new WebParameter("oauth_timestamp", timestamp),
                                         new WebParameter("oauth_version", Version ?? "1.0")
                                     };

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

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

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

            if (!IsNullOrBlank(SessionHandle))
            {
                authParameters.Add(new WebParameter("oauth_session_handle", SessionHandle));
            }

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

示例4: BuildRequestParameters

        protected WebParameterCollection BuildRequestParameters()
        {
            var parameters = new Dictionary<string, string>();
            var properties = Info.GetType().GetProperties();

            Info.ParseAttributes<ParameterAttribute>(properties, parameters);

            var collection = new WebParameterCollection();
            parameters.ForEach(p => collection.Add(new WebParameter(p.Key, p.Value)));

            return collection;
        }
开发者ID:apanda,项目名称:TweetSharpForWinMo,代码行数:12,代码来源:WebQueryBase.cs

示例5: 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

示例6: 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

示例7: AddOAuthData

        private void AddOAuthData(IRestClient client, IRestRequest request, OAuthWorkflow workflow)
        {
            var url = client.BuildUri(request).ToString();
            var queryStringStart = url.IndexOf('?');

            if (queryStringStart != -1)
                url = url.Substring(0, queryStringStart);

            OAuthWebQueryInfo oauth;
#if PocketPC
            var method = request.Method.ToString().ToUpper();
#else
            var method = request.Method.ToString().ToUpperInvariant();
#endif

            var parameters = new WebParameterCollection();

            // include all GET and POST parameters before generating the signature
            // according to the RFC 5849 - The OAuth 1.0 Protocol
            // http://tools.ietf.org/html/rfc5849#section-3.4.1
            // if this change causes trouble we need to introduce a flag indicating the specific OAuth implementation level,
            // or implement a seperate class for each OAuth version
            if (!request.AlwaysMultipartFormData && !request.Files.Any())
            {
                foreach (var p in client.DefaultParameters.Where(p => p.Type == ParameterType.GetOrPost || p.Type == ParameterType.QueryString))
                {
                    parameters.Add(new WebPair(p.Name, p.Value.ToString()));
                }

                foreach (var p in request.Parameters.Where(p => p.Type == ParameterType.GetOrPost || p.Type == ParameterType.QueryString))
                {
                    parameters.Add(new WebPair(p.Name, p.Value.ToString()));
                }
            }
            else
            {
                // if we are sending a multipart request, only the "oauth_" parameters should be included in the signature
                foreach (var p in client.DefaultParameters.Where(
                    p => (p.Type == ParameterType.GetOrPost || p.Type == ParameterType.QueryString) && p.Name.StartsWith("oauth_")))
                {
                    parameters.Add(new WebPair(p.Name, p.Value.ToString()));
                }

                foreach (var p in request.Parameters.Where(
                    p => (p.Type == ParameterType.GetOrPost || p.Type == ParameterType.QueryString) && p.Name.StartsWith("oauth_")))
                {
                    parameters.Add(new WebPair(p.Name, p.Value.ToString()));
                }
            }

            switch (this.Type)
            {
                case OAuthType.RequestToken:
                    workflow.RequestTokenUrl = url;
                    oauth = workflow.BuildRequestTokenInfo(method, parameters);
                    break;

                case OAuthType.AccessToken:
                    workflow.AccessTokenUrl = url;
                    oauth = workflow.BuildAccessTokenInfo(method, parameters);
                    break;

                case OAuthType.ClientAuthentication:
                    workflow.AccessTokenUrl = url;
                    oauth = workflow.BuildClientAuthAccessTokenInfo(method, parameters);
                    break;

                case OAuthType.ProtectedResource:
                    oauth = workflow.BuildProtectedResourceInfo(method, parameters, url);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }

            switch (this.ParameterHandling)
            {
                case OAuthParameterHandling.HttpAuthorizationHeader:
                    parameters.Add("oauth_signature", oauth.Signature);
                    request.AddHeader("Authorization", this.GetAuthorizationHeader(parameters));
                    break;

                case OAuthParameterHandling.UrlOrPostParameters:
                    parameters.Add("oauth_signature", oauth.Signature);

                    foreach (var parameter in parameters.Where(parameter =>
                        !parameter.Name.IsNullOrBlank() &&
                        (parameter.Name.StartsWith("oauth_") || parameter.Name.StartsWith("x_auth_"))))
                    {
                        request.AddParameter(parameter.Name, HttpUtility.UrlDecode(parameter.Value));
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
开发者ID:mgulubov,项目名称:RestSharpHighQualityCodeTeamProject,代码行数:97,代码来源:OAuth1Authenticator.cs


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