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


C# Portable.RestRequest类代码示例

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


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

示例1: App

 public App()
 {
     this.serializer = new JsonSerializer ();
     this.result = JsonConvert.DeserializeObject ("{ \"auth\":\"12345\"}")
                     as Dictionary<string, string>;
     this.restClient = new RestClient ();
     var request = new RestRequest (new Uri ("http://google.com"), HttpMethod.Get);
     this.httpContent = restClient.GetContent (request);
     this.imageButton = new ImageButton();
     this.imageButton.Text = "Image Text";
     this.imageButton.Source = "icon.png";
     this.checkbox = new CheckBox ();
     this.checkbox.Checked = true;
     // The root page of your application
     MainPage = new ContentPage {
         Content = new StackLayout {
             VerticalOptions = LayoutOptions.Center,
             Children = {
                 new Label {
                     XAlign = TextAlignment.Center,
                     Text = "Welcome to Xamarin Forms!"
                 }
             }
         }
     };
 }
开发者ID:klimaye,项目名称:XamarinFormsSizeTest,代码行数:26,代码来源:SizeTest.cs

示例2: Get

 public async Task<Club> Get(int id)
 {
     var request = new RestRequest(EndPoint + "/{id}", Method.GET);
     request.AddParameter("id", id, ParameterType.UrlSegment);
     var response = await _client.RestClient.Execute<Club>(request);
     return response.Data;
 }
开发者ID:gabornemeth,项目名称:StravaSharp,代码行数:7,代码来源:ClubClient.cs

示例3: Get

 public async Task<Activity> Get(long activityId, bool includeAllEfforts = true)
 {
     var request = new RestRequest(EndPoint + "/{id}", Method.GET);
     request.AddParameter("id", activityId, ParameterType.UrlSegment);
     var response = await _client.RestClient.Execute<Activity>(request);
     return response.Data;
 }
开发者ID:gabornemeth,项目名称:StravaSharp,代码行数:7,代码来源:ActivityClient.cs

示例4: ExecuteHttpRequest

    /// <summary>
    /// Executes a call to a web method without any persistence.
    /// </summary>
    /// <param name="restRequest">the <see cref="RestRequest"/></param>
    /// <param name="attempsCount">the current attemp number</param>
    /// <returns>The content of the </returns>
    public virtual async Task<Tuple<byte[], double>> ExecuteHttpRequest(RestRequest restRequest, int attempsCount = 0)
    {
      attempsCount++;
      var callType = restRequest.Method.ToString();
      var resource = client.BuildUri(restRequest).AbsoluteUri;

      Debug("Running the HTTP '" + callType + "' request '" + resource + "'");

      var start = TimeSpan.FromTicks(DateTime.Now.Ticks);
      var rawResponse = await client.Execute(restRequest);
      var end = TimeSpan.FromTicks(DateTime.Now.Ticks);
      var responseTimeInMs = (end - start).TotalMilliseconds; 
      var data = rawResponse.RawBytes;
      var tuple = new Tuple<byte[], double>(data, responseTimeInMs);
      var statusCode = rawResponse.StatusCode;

      Debug("The call to the HTTP " + callType + " request '" + resource + "' took " + responseTimeInMs + " ms and returned the status code '" + statusCode + "'");

      if (statusCode != HttpStatusCode.OK)
      {
        if (attempsCount < M4MBaseWebServiceCaller.ATTEMPTS_COUNT_MAX)
        {
          tuple = await ExecuteHttpRequest(restRequest, attempsCount);
        }
        else
        {
          OnHttpStatusCodeNotOk(resource, statusCode);
        }
      }

      return tuple;
    }
开发者ID:smartnsoft,项目名称:ModernApp4Me,代码行数:38,代码来源:M4MBaseWebServiceCaller.cs

示例5: CreateAccountInfoRequest

        public RestRequest CreateAccountInfoRequest()
        {
            var request = new RestRequest("{version}/account/info", HttpMethod.Get);
            request.AddParameter("version", _version, ParameterType.UrlSegment);

            return request;
        }
开发者ID:gabornemeth,项目名称:DropNet,代码行数:7,代码来源:RequestHelper.cs

示例6: CreateAccessTokenRequest

        public RestRequest CreateAccessTokenRequest()
        {
            var request = new RestRequest("{version}/oauth/access_token", HttpMethod.Get);
            request.AddParameter("version", _version, ParameterType.UrlSegment);

            return request;
        }
开发者ID:gabornemeth,项目名称:DropNet,代码行数:7,代码来源:RequestHelper.cs

示例7: GetPublicationsIds

        public PubMedPublicationIdsResult GetPublicationsIds(PubMedQueryFilter filter)
        {
            var restClient = new RestClient(ServiceURLs.ESearchBaseURL);

            var restRequest = new RestRequest();
            restRequest.AddParameter("db", databaseName, ParameterType.QueryString);
            restRequest.AddParameter("retmode", "json", ParameterType.QueryString);
            restRequest.AddParameter("retstart", (filter.Skip * filter.Take), ParameterType.QueryString);
            restRequest.AddParameter("term", filter.Query, ParameterType.QueryString);
            restRequest.AddParameter("retmax", filter.Take, ParameterType.QueryString);
            if (filter.RelDate != DateTime.MinValue)
            {
                var pmDate = PubMedDateOperations.DatetimeToPubMedDate(filter.RelDate);
                restRequest.AddParameter("reldate", pmDate, ParameterType.QueryString);
            }

            var waitTime = PubMedThrottler.GetWaitTime();
            Thread.Sleep(waitTime);
            var response = restClient.Execute<PubMedResponse>(restRequest).Result;

            if (response.Data == null)
                throw new Exception("No Response From The Server");

            var result = new PubMedPublicationIdsResult();
            result.PubMedIdCollection = new List<string>();
            response.Data.esearchresult.idlist.ForEach(r => result.PubMedIdCollection.Add(r));

            return result;
        }
开发者ID:jn7163,项目名称:Pubmed.Explorer,代码行数:29,代码来源:PubMedRequest.cs

示例8: Register

 public int Register(string password)
 {
     var request = new RestRequest("api/Register", HttpMethod.Post);
     request.AddParameter("DeviceId", _deviceId);
     request.AddParameter("Password", password);
     return Execute<int>(request);
 }
开发者ID:QRyptoWire,项目名称:qrypto-wire,代码行数:7,代码来源:QryptoWireServiceClient.cs

示例9: Login

 public bool Login(string password)
 {
     var request = new RestRequest(ApiUris.Login, HttpMethod.Post);
     request.AddParameter("DeviceId", _deviceId);
     request.AddParameter("Password", password);
     _sessionId = Execute<string>(request);
     return _sessionId != null;
 }
开发者ID:QRyptoWire,项目名称:qrypto-wire,代码行数:8,代码来源:QryptoWireServiceClient.cs

示例10: GetUsuarios

        public async Task<ICollection<UsuarioModel>> GetUsuarios()
        {
            var request = new RestRequest("Usuario") {Method = Method.GET};

            var response = await client.Execute<ICollection<UsuarioModel>>(request);
            if (response.IsSuccess)
                return response.Data;
            return null;
        }
开发者ID:M1r3l,项目名称:RedSocialXamarin,代码行数:9,代码来源:ServicioDatos.cs

示例11: Explore

 public async Task<List<SegmentSummary>> Explore(LatLng southWest, LatLng northEast, ActivityType activityType = ActivityType.Ride)
 {
     var request = new RestRequest(EndPoint + "/explore", Method.GET);
     request.AddParameter("bounds",
         string.Format("{0},{1},{2},{3}", southWest.Latitude.ToString(CultureInfo.InvariantCulture), southWest.Longitude.ToString(CultureInfo.InvariantCulture),
         northEast.Latitude.ToString(CultureInfo.InvariantCulture), northEast.Longitude.ToString(CultureInfo.InvariantCulture)));
     var response = await _client.RestClient.Execute<SegmentCollection>(request);
     return response.Data.Segments;
 }
开发者ID:gabornemeth,项目名称:StravaSharp,代码行数:9,代码来源:SegmentClient.cs

示例12: AddUsuario

 public async Task<UsuarioModel> AddUsuario(UsuarioModel usuario)
 {
     var request = new RestRequest("Usuario")
     {
         Method = Method.POST //Otra forma de hacerlo
     };
     request.AddJsonBody(usuario);
     var response = await client.Execute<UsuarioModel>(request);
     return response.IsSuccess ? response.Data : null;
 }
开发者ID:paulLozano90,项目名称:RedContactos,代码行数:10,代码来源:ServicioDatos.cs

示例13: CreateCountriesRequest

        public static RestRequest CreateCountriesRequest(int page, int countriesPerPage, RequestFormat format)
        {
            var restReq = new RestRequest(HttpMethod.Get);

            restReq.AddQueryParameter("format", format.ToString());
            restReq.AddQueryParameter("page", page);
            restReq.AddQueryParameter("per_page", countriesPerPage);

            return restReq;
        }
开发者ID:olegtyshcneko,项目名称:mvvmcrosspoc,代码行数:10,代码来源:RequestsFactory.cs

示例14: AddMensaje

        public async Task<MensajeModel> AddMensaje(MensajeModel mensaje)
        {
            var request = new RestRequest("Mensaje");
            request.Method = Method.POST;
            request.AddJsonBody(mensaje);
            var response = await client.Execute<MensajeModel>(request);

            if (response.IsSuccess) return response.Data;
            return null;
        }
开发者ID:M1r3l,项目名称:RedSocialXamarin,代码行数:10,代码来源:ServicioDatos.cs

示例15: GetUsuariosId

 public async Task<UsuarioModel> GetUsuariosId(int id)
 {
     var request = new RestRequest("Usuario");
     request.Method = Method.GET;
     request.AddQueryParameter("id", id);
     var response = await client.Execute<UsuarioModel>(request);
     if (response.IsSuccess)
         return response.Data;
     return null;
 }
开发者ID:M1r3l,项目名称:RedSocialXamarin,代码行数:10,代码来源:ServicioDatos.cs


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