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


C# RestSharp.Parameter类代码示例

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


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

示例1: AddParameter

 public void AddParameter(string name, string value)
 {
     Parameter parm = new RestSharp.Parameter();
     parm.Name = name;
     parm.Value = value;
     parameters.Add(parm);
 }
开发者ID:nguyenvanduocit,项目名称:FlickrDownloader,代码行数:7,代码来源:SearchParameter.cs

示例2: Resolve

        public SpreedlyStatus Resolve(Parameter statusHeader)
        {
            if (statusHeader == null)
                throw new ArgumentNullException("statusHeader");

            return ResolveStatusCode(GetStatusCodeString(statusHeader.Value.ToString()));
        }
开发者ID:danstuken,项目名称:Spreedly.Net,代码行数:7,代码来源:StatusResolver.cs

示例3: RetornaUsuario

        public Usuario RetornaUsuario(string id)
        {
            Usuario u;
            Parameter at = new Parameter();
            Parameter at1 = new Parameter();
            List<Parameter> param = new List<Parameter>();

            //Alimentando parametros
            //at1.Name = "access_token";
            //at1.Value = m.AccessToken;

            at.Name = "user_id";
            at.Value = id;

            param.Add(at);
            //param.Add(at1);

            RestResponse resp = (RestResponse)m.Get("/users/" + id);

            if (resp.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var a = new JsonSerializerSettings();
                u = JsonConvert.DeserializeObject<Usuario>(resp.Content);

                return u;
            }
            else
            {
                throw new Exception("Falha ao tentar recuperar a Usuario");
            }
        }
开发者ID:ricardochaves,项目名称:MasterControl,代码行数:31,代码来源:LerML.cs

示例4: BeforeGetUserInfo

        /// <summary>
        /// Called just before issuing request to third-party service when everything is ready.
        /// Allows to add extra parameters to request or do any other needed preparations.
        /// </summary>
        protected override void BeforeGetUserInfo(BeforeAfterRequestArgs args)
        {
            // Source document
            // http://dev.odnoklassniki.ru/wiki/pages/viewpage.action?pageId=12878032

            args.Request.AddParameter("application_key", _configuration.ClientPublic);
            args.Request.AddParameter("method", "users.getCurrentUser");

            // workaround for current design, oauth_token is always present in URL, so we need emulate it for correct request signing 
            var fakeParam = new Parameter() { Name = "oauth_token", Value = AccessToken };
            args.Request.AddParameter(fakeParam);

            // Signing.
            // Call API methods using access_token instead of session_key parameter
            // Calculate every request signature parameter sig using a little bit different way described in
            // http://dev.odnoklassniki.ru/wiki/display/ok/Authentication+and+Authorization
            // sig = md5( request_params_composed_string+ md5(access_token + application_secret_key)  )
            // Don't include access_token into request_params_composed_string
            string signature = string.Concat(args.Request.Parameters.OrderBy(x => x.Name).Select(x => string.Format("{0}={1}", x.Name, x.Value)).ToList());
            signature = (signature + (AccessToken + _configuration.ClientSecret).GetMd5Hash()).GetMd5Hash();

            // Removing fake param to prevent dups
            args.Request.Parameters.Remove(fakeParam);

            args.Request.AddParameter("access_token", AccessToken);
            args.Request.AddParameter("sig", signature);
        }
开发者ID:kekekeks,项目名称:OAuth2,代码行数:31,代码来源:OdnoklassnikiClient.cs

示例5: Parse

 /// <summary>
 /// Parses the specified header and returns a collection of warning headers discovered and parsed.
 /// </summary>
 /// <param name="header">The header to parse.</param>
 /// <returns>A collection of warning headers that were discovered in the header and parsed.</returns>
 public static IEnumerable<HttpWarning> Parse(Parameter header)
 {
     if (header != null && header.Value != null)
     {
         foreach (Match match in regex.Matches(header.Value.ToString()))
         {
             yield return HttpWarning.Parse(match.Value);
         }
     }
 }
开发者ID:Herbert42,项目名称:gedcomx-csharp,代码行数:15,代码来源:HttpWarning.cs

示例6: AddDefaultParameter

		/// <summary>
		/// Add a parameter to use on every request made with this client instance
		/// </summary>
		/// <param name="restClient">The IRestClient instance</param>
		/// <param name="p">Parameter to add</param>
		/// <returns></returns>
		public static void AddDefaultParameter(this IRestClient restClient, Parameter p)
		{
			if (p.Type == ParameterType.RequestBody)
			{
				throw new NotSupportedException(
					"Cannot set request body from default headers. Use Request.AddBody() instead.");
			}

			restClient.DefaultParameters.Add(p);
		}
开发者ID:fmmendo,项目名称:RestSharp,代码行数:16,代码来源:RestClientExtensions.cs

示例7: HandleErrors

		public void HandleErrors ()
		{
			Meli.ApiUrl = "http://localhost:3000";
			Meli m = new Meli (123456, "client secret", "invalid token");

			var p = new Parameter ();
			p.Name = "access_token";
			p.Value = m.AccessToken;
			var ps = new List<Parameter> ();
			ps.Add (p);
			var response = m.Get ("/users/me", ps);
			Assert.AreEqual (HttpStatusCode.Forbidden, response.StatusCode);
		}
开发者ID:marciomancinelli,项目名称:net-sdk,代码行数:13,代码来源:MeliTest.cs

示例8: GetContacts

 public IEnumerable<CrmContact> GetContacts(long responsibleUserId)
 {
     var contacts = new List<CrmContact>();
     for (var offset = 0;; offset += _crmConfig.LimitRows ?? 500)
     {
         _crmConfig.LimitOffset = offset;
         var parameterResponsibleUserId = new Parameter {Name = "responsible_user_id", Value = responsibleUserId, Type = ParameterType.QueryString};
         var contactsList = AmoMethod.Get<CrmContactResponse>(_crmConfig, parameterResponsibleUserId);
         if (contactsList == null)
             break;
         contacts.AddRange(contactsList.Response.Contacts);
     }
     return contacts;
 }
开发者ID:gitter-badger,项目名称:AmoCrmIntegration,代码行数:14,代码来源:AmoCrmService.cs

示例9: GetContacts

 public IEnumerable<CrmContact> GetContacts(string query)
 {
     var contacts = new List<CrmContact>();
     for (var offset = 0;; offset += _crmConfig.LimitRows ?? 500)
     {
         _crmConfig.LimitOffset = offset;
         var parameterQuery = new Parameter {Name = "query", Value = query, Type = ParameterType.QueryString};
         var contactsList = AmoMethod.Get<CrmGetContactResponse>(_crmConfig, parameterQuery);
         if (contactsList == null)
             break;
         contacts.AddRange(contactsList.Response.Contacts);
     }
     return contacts;
 }
开发者ID:spoofi,项目名称:AmoCrmIntegration,代码行数:14,代码来源:AmoCrmService.cs

示例10: ToSingleParameter

        /// <summary>
        /// Parameterizes this <see cref="ShopifyOrderFilterOptions"/> class, with special handling for <see cref="Ids"/>.
        /// </summary>
        /// <param name="propName">The name of the property. Will match the property's <see cref="JsonPropertyAttribute"/> name — 
        /// rather than the real property name — where applicable. Use <paramref name="property"/>.Name to get the real name.</param>
        /// <param name="value">The property's value.</param>
        /// <param name="property">The property itself.</param>
        /// <param name="type">The type of parameter to create.</param>
        /// <returns>The new parameter.</returns>
        public override Parameter ToSingleParameter(string propName, object value, PropertyInfo property, ParameterType type)
        {
            if (propName == "ids" || propName == "Ids")
            {
                //RestSharp does not automatically convert arrays into querystring params.
                var param =  new Parameter()
                {
                    Name = propName,
                    Type = type,
                    Value = string.Join(",", value as IEnumerable<long> )
                };

                return param;
            }
            
            return base.ToSingleParameter(propName, value, property, type);
        }
开发者ID:squallop,项目名称:ShopifySharp,代码行数:26,代码来源:ShopifyOrderFilterOptions.cs

示例11: GetWithRefreshToken

		public void GetWithRefreshToken ()
		{
			Meli.ApiUrl = "http://localhost:3000";

			Meli m = new Meli (123456, "client secret", "expired token", "valid refresh token");

			var p = new Parameter ();
			p.Name = "access_token";
			p.Value = m.AccessToken;

			var ps = new List<Parameter> ();
			ps.Add (p);
			var response = m.Get ("/users/me", ps);

			Assert.AreEqual (HttpStatusCode.OK, response.StatusCode);
			Assert.IsNotNullOrEmpty (response.Content);
		}
开发者ID:marciomancinelli,项目名称:net-sdk,代码行数:17,代码来源:MeliTest.cs

示例12: ResponderPergunta

        public void ResponderPergunta(decimal idQuestion, string texto)
        {
            try
            {
                Parameter at = new Parameter();
                List<Parameter> param = new List<Parameter>();

                //Alimentando parametros
                at.Name = "access_token";
                at.Value = m.AccessToken;

                param.Add(at);

                m.Post("/answers", param, new { question_id = idQuestion, text = texto });

            }
            catch (Exception ex)
            {

                throw new Exception("Erro na rotina ResponderPergunta", ex);
            }
        }
开发者ID:ricardochaves,项目名称:MasterControl,代码行数:22,代码来源:Posts.cs

示例13: RetornarOrdens

        public ListOrder RetornarOrdens(Usuario u, Int32 ofset)
        {
            ListOrder o;
            Parameter at = new Parameter();
            Parameter seller = new Parameter();
            Parameter offset = new Parameter();
            List<Parameter> param = new List<Parameter>();

            //Alimentando parametros
            at.Name = "access_token";
            at.Value = m.AccessToken;

            seller.Name = "seller";
            seller.Value = u.id;

            offset.Name = "offset";
            offset.Value = ofset;

            //Adicionando na lista
            param.Add(seller);
            param.Add(at);
            param.Add(offset);

            RestResponse resp = (RestResponse)m.Get("/orders/search", param);
            //offset
            if (resp.StatusCode == System.Net.HttpStatusCode.OK)
            {

                var a = new JsonSerializerSettings();
                o = JsonConvert.DeserializeObject<ListOrder>(resp.Content);

                return o;
            }
            else
            {
                throw new Exception("Falha ao tentar recuperar a lista de ordens");
            }
        }
开发者ID:ricardochaves,项目名称:MasterControl,代码行数:38,代码来源:LerML.cs

示例14: RetonarQuestion

        public Question RetonarQuestion(string resource)
        {
            try
            {
                Question q;
                Parameter at = new Parameter();
                List<Parameter> param = new List<Parameter>();

                //Alimentando parametros
                at.Name = "access_token";
                at.Value = m.AccessToken;

                param.Add(at);

                RestResponse resp = (RestResponse)m.Get(resource, param);

                if (resp.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var a = new JsonSerializerSettings();
                    q = JsonConvert.DeserializeObject<Question>(resp.Content);

                    FinalizaML(m.AccessToken, m.RefreshToken);

                    return q;

                }
                else
                {
                    throw new Exception(string.Format("Falha ao tentar recuperar a pergunta {0}  resp.StatusCode = {1} {0} resource = {2} {0}", Environment.NewLine, resp.StatusCode, resource));
                }

            }
            catch (Exception ex)
            {

                throw new Exception("Erro na rotina RetonarQuestion.", ex);
            }
        }
开发者ID:ricardochaves,项目名称:MasterControl,代码行数:38,代码来源:ControlaMeli.cs

示例15: RetornaOrder

        public Order RetornaOrder(string codigo)
        {
            try
            {

                Order q;
                Parameter at = new Parameter();
                List<Parameter> param = new List<Parameter>();

                //Alimentando parametros
                at.Name = "access_token";
                at.Value = m.AccessToken;

                //Adicionando na lista
                param.Add(at);

                RestResponse resp = (RestResponse)m.Get(codigo, param);

                if (resp.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var a = new JsonSerializerSettings();
                    q = JsonConvert.DeserializeObject<Order>(resp.Content);

                    FinalizaML(m.AccessToken, m.RefreshToken);

                    return q;
                }
                else
                {
                    throw new Exception(String.Format("Ordem não encontrada. {0} codigo: {1} {0}",Environment.NewLine, codigo));
                }

            }
            catch (Exception ex)
            {

                throw new Exception(String.Format("Erro na rotina RetornaOrder: {0} codigo: {1} {0}", Environment.NewLine, codigo), ex);
            }
        }
开发者ID:ricardochaves,项目名称:MasterControl,代码行数:39,代码来源:ControlaMeli.cs


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