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


C# RestRequest.ToString方法代码示例

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


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

示例1: Execute

        public void Execute(IJobExecutionContext context)
        {
            var settings = context.JobDetail.JobDataMap["settings"] as PollingSettings;
            if (settings == null)
            {
                _logger.Error("Error retrieving settings for job {0}".Fmt(context.JobDetail.Key));
                return;
            }

            _logger.Info("Executing polling job for client {0} provider {1}".Fmt(settings.ClientId, settings.Provider));

            // retrieve dispatcher
            var dispatcher = SmsDispatcherFactory.GetDispatcherByName(settings.Provider, settings.DispatcherSettings);

            // setup rest client - no need for validation here, it's already in a valid URI
            _client.BaseUrl = new Uri(settings.PollingUrl.Scheme + "://" + settings.PollingUrl.Authority + "/");

            // build request
            var path = HttpUtility.UrlDecode(settings.PollingUrl.PathAndQuery);
            var request = new RestRequest(path, Method.GET);
            request.AddUrlSegment("clientId", settings.ClientId);

            // retrieve response
            var response = _client.Execute<List<SmsDispatch>>(request);
            if (response.ResponseStatus != ResponseStatus.Completed)
            {
                _logger.Error("Error retrieving jobs from {0}".Fmt(request.ToString()));
                return;
            }

            try
            {
                // dispatch
                var results = dispatcher.Dispatch(response.Data).ToList();
                var stats = new
                {
                    Processed = results.Count(),
                    Successful = results.Count(x => x.Error == false),
                    Failed = results.Count(x => x.Error)
                };

                _logger.Info("{0} records processed - {1} successful and {2} failed".Fmt(stats.Processed, stats.Successful, stats.Failed ));

                UpdateDispatchRecords(results);
            }
            catch (Exception ex)
            {
                _logger.Error("Unable to dispatch {0} dispatches - error {1}".Fmt(response.Data.Count(), ex));
            }
        }
开发者ID:danbyrne84,项目名称:DispatcherSvc,代码行数:50,代码来源:DispatcherPollingJob.cs

示例2: Main

        public static void Main(string[] args)
        {
            var client = new RestClient("http://127.0.0.1:8080/api/");
            client.Options (new RestRequest () {RequestFormat = DataFormat.Json,  });

            var user = new
            {
                username = "MikkelMus10",
                password = "hej%Hej123",
                passwordConfirm = "hej%Hej123"
            };

            var request = new RestRequest("user/register", Method.POST);
            request.RequestFormat = DataFormat.Json;
            request.AddBody(user);
            Console.WriteLine (request.ToString ());

            IRestResponse response = client.Execute(request);

            Console.WriteLine (response.Content);
            Console.ReadKey ();
        }
开发者ID:prozum,项目名称:solitude,代码行数:22,代码来源:Program.cs

示例3: GetTrades

        /// <summary>
        /// returns the trading history - an array of user’s trades(trade objects).
        /// /api/1/trading/trades
        /// </summary>
        /// <param name="by">Selects if filtering and sorting is performed by trade_id or by timestamp, Required
        /// possible values: "trade_id" or "ts"</param>
        /// <param name="start_index">Zero-based index. Default value is 0, Required</param>
        /// <param name="max_results"> 	Maximum quantity of returned results, at most 1000, Required</param>
        /// <param name="symbols">Comma-separated list of currency symbols</param>
        /// <param name="sort">Trades are sorted ascending (default) or descending</param>
        /// <param name="from">Returns trades with trade_id > specified trade_id (if by=trade_id) or returns trades with timestamp >= specified timestamp(ifby=ts`)</param>
        /// <param name="till">Returns trades with trade_id < specified trade_id (if by=trade_id) or returns trades with timestamp < specified timestamp (if by=ts)</param>
        /// <returns></returns>
        public async Task<Trades> GetTrades(string by = "trade_id", int start_index = 0, int max_results = 1000, string symbols = null, string sort = "asc",
            string from = null, string till = null)
        {
            var request = new RestRequest("/api/1/trading/trades");

            request.Parameters.Add(new Parameter { Value = by, Name = "by", Type = ParameterType.GetOrPost });
            request.Parameters.Add(new Parameter { Value = start_index, Name = "start_index", Type = ParameterType.GetOrPost });
            request.Parameters.Add(new Parameter { Value = max_results, Name = "max_results", Type = ParameterType.GetOrPost });
            if (!string.IsNullOrEmpty(symbols))
                request.Parameters.Add(new Parameter { Value = symbols, Name = "symbols", Type = ParameterType.GetOrPost });
            if (!string.IsNullOrEmpty(sort))
                request.Parameters.Add(new Parameter { Value = sort, Name = "sort", Type = ParameterType.GetOrPost });
            if (!string.IsNullOrEmpty(from))
                request.Parameters.Add(new Parameter { Value = from, Name = "from", Type = ParameterType.GetOrPost });
            if (!string.IsNullOrEmpty(till))
                request.Parameters.Add(new Parameter { Value = till, Name = "till", Type = ParameterType.GetOrPost });

            var str = request.ToString();
            return await _api.Execute(request);
        }
开发者ID:misha-bilous,项目名称:HitBtcApi,代码行数:33,代码来源:Trading.cs


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