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


C# IRestRequest类代码示例

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


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

示例1: CanPreAuthenticate

 /// <summary>
 /// Does the authentication module supports pre-authentication?
 /// </summary>
 /// <param name="client">Client executing this request</param>
 /// <param name="request">Request to authenticate</param>
 /// <param name="credentials">The credentials to be used for the authentication</param>
 /// <returns>true when the authentication module supports pre-authentication</returns>
 public bool CanPreAuthenticate(IRestClient client, IRestRequest request, ICredentials credentials)
 {
     var cred = credentials?.GetCredential(client.BuildUri(request, false), AuthenticationMethod);
     if (cred == null)
         return false;
     return true;
 }
开发者ID:evnik,项目名称:restsharp.portable,代码行数:14,代码来源:SimpleAuthenticator.cs

示例2: IsCanProcessRequest

 protected override bool IsCanProcessRequest(IRestRequest request)
 {
     return (request.Verb == HttpVerb.Post || request.Verb == HttpVerb.Put)
         && request.GetType() == typeof(RestRequest)
         && request.Parameters != null
         && request.Parameters.Any(p => p.Value is FileParameter);
 }
开发者ID:VeselovAndrey,项目名称:RestArt,代码行数:7,代码来源:MultipartFormDataMessageBuilder.cs

示例3: ApplyOptions

        public void ApplyOptions(IRestRequest request, bool isGet)
        {
            if (_options == null)
            {
                return;
            }
            ApplyOptionsStrategy applyOptionsStrategy = isGet
                                                            ? (ApplyOptionsStrategy)
                                                              new GetApplyOptionsStrategy(request, _options)
                                                            : new PostApplyOptionsStrategy(request, _options);
            if (_options.Pretty)
            {
                applyOptionsStrategy.ApplyPretty();
            }

            if (_options.Fields != null && _options.Fields.Count > 0)
            {
                applyOptionsStrategy.ApplyFields();
            }

            if (_options.Expand != null && _options.Expand.Count > 0)
            {
                applyOptionsStrategy.ApplyExpand();
            }
            applyOptionsStrategy.Finish();
        }
开发者ID:pocheptsov,项目名称:nasana,代码行数:26,代码来源:AsanaOptionsApplier.cs

示例4: PopulateSubEntities

 private void PopulateSubEntities(IRestRequest request)
 {
     new LobImageFilePopulator(_definition.Front, "front").Populate(request);
     new LobImageFilePopulator(_definition.Back, "back").Populate(request);
     if (_definition.Data != null) new DataPopulator(_definition.Data).Populate(request);
     if (_definition.MetaData != null) new MetaDataPopulator(_definition.MetaData).Populate(request);
 }
开发者ID:CRodriguez25,项目名称:lob-dotnet,代码行数:7,代码来源:AreaMailingDefinitionPopulator.cs

示例5: ReplaceAcceptWithJson

 private void ReplaceAcceptWithJson(IRestRequest restRequest)
 {
     foreach (var parameter in restRequest.Parameters.Where(p => p.Name == "Accept"))
     {
         parameter.Value = "application/json";
     }
 }
开发者ID:DefiSolutions,项目名称:YouTrack.Rest,代码行数:7,代码来源:RestFileRequestFactory.cs

示例6: RestException

 public RestException(IRestRequest request, IRestResponse response)
     : base(string.Format("The endpoint at '{0}' didn't respond with 'OK'. Instead it was '{1}'.",
         response.ResponseUri, response.StatusCode), response.ErrorException??new Exception(response.Content))
 {
     Request = request;
     Response = response;
 }
开发者ID:AcklenAvenue,项目名称:Pepino,代码行数:7,代码来源:RestException.cs

示例7: BaseRestService

 public BaseRestService(IRestHandler restHandler, IFormat formator, IRestRequest restRequest)
 {
     _restHandler = restHandler;
     _formator = formator;
     _restRequest = restRequest;
     Initialize();
 }
开发者ID:smacinn,项目名称:IRestService,代码行数:7,代码来源:baseRestService.cs

示例8: GetBasicContent

        /// <summary>
        /// Gets the basic content (without files) for a request
        /// </summary>
        /// <param name="client">The REST client that will execute the request</param>
        /// <param name="request">REST request to get the content for</param>
        /// <returns>The HTTP content to be sent</returns>
        internal static IHttpContent GetBasicContent([CanBeNull] this IRestClient client, IRestRequest request)
        {
            IHttpContent content;
            var parameters = client.MergeParameters(request);
            var body = parameters.FirstOrDefault(x => x.Type == ParameterType.RequestBody);
            if (body != null)
            {
                content = request.GetBodyContent(body);
            }
            else
            {
                if (client.GetEffectiveHttpMethod(request) == Method.POST)
                {
                    var getOrPostParameters = parameters.GetGetOrPostParameters().ToList();
                    if (getOrPostParameters.Count != 0)
                    {
                        content = new PostParametersContent(getOrPostParameters);
                    }
                    else
                    {
                        content = null;
                    }
                }
                else
                {
                    content = null;
                }
            }

            return content;
        }
开发者ID:ReachContact,项目名称:restsharp.portable,代码行数:37,代码来源:RestClientExtensions.cs

示例9: Authenticate

 /// <summary>
 /// Modifies the request to ensure that the authentication requirements are met.
 /// </summary>
 /// <param name="client">Client executing this request</param>
 /// <param name="request">Request to authenticate</param>
 public void Authenticate(IRestClient client, IRestRequest request)
 {
     // only add the Authorization parameter if it hasn't been added by a previous Execute
     if (request.Parameters.Any(p => p.Name != null && p.Name.Equals("Authorization", StringComparison.OrdinalIgnoreCase)))
         return;
     request.AddParameter("Authorization", this._authHeader, ParameterType.HttpHeader);
 }
开发者ID:ATLCTO,项目名称:CustomerIOSharp,代码行数:12,代码来源:FixedHttpBasicAuthenticator.cs

示例10: Build

        public HttpRequestMessage Build(IRestRequest request, IDictionary<string, string> persistentHeaders)
        {
            if (!this.IsCanProcessRequest(request))
                return null;

            HttpRequestMessage message = this.BuildMessage(request);

            // Set headers
            message.Headers.Add("Accept", "application/json");

            // Add persistent headers
            if (request.Headers != null) {
                foreach (var header in request.Headers)
                    this.AddHeader(header.Key, header.Value, message);
            }

            // Add message headers
            if (persistentHeaders != null) {
                foreach (var header in persistentHeaders)
                    if (request.Headers == null || !request.Headers.ContainsKey(header.Key))
                        this.AddHeader(header.Key, header.Value, message);
            }

            return message;
        }
开发者ID:VeselovAndrey,项目名称:RestArt,代码行数:25,代码来源:MessageBuilderBase.cs

示例11: Apply

 internal void Apply(IRestRequest request)
 {
     _ops.ForEach((op) =>
     {
         request.AddQueryParameter(op.Type.ToString(), op.Value);
     });
 }
开发者ID:tvhnet2014,项目名称:stream-net,代码行数:7,代码来源:FeedFilter.cs

示例12: Authenticate

        public void Authenticate(IRestClient client, IRestRequest request)
        {
            if (request.Parameters.Exists(p => p.Name.Equals("Cookie", StringComparison.InvariantCultureIgnoreCase)))
                return;

            request.AddParameter("cookie", _authHeader, ParameterType.HttpHeader);
        }
开发者ID:gooodhub,项目名称:Jira.NET,代码行数:7,代码来源:CookieBasedAuthenticator.cs

示例13: BuildDebugUri

 /// <summary>
 /// Assembles URL to call based on parameters, method and resource
 /// </summary>
 /// <param name="client">RestClient performing the execution</param>
 /// <param name="request">RestRequest to execute</param>
 /// <returns>Assembled System.Uri</returns>
 /// <remarks>
 /// RestClient's BuildUri purposefully leaves off the parameters from the uri it builds when the request 
 /// is a POST, PUT, or PATCH.  This extension method aims to undo this feature for debugging reasons
 /// </remarks>
 public static Uri BuildDebugUri(this IRestClient client, IRestRequest request)
 {
     var uri = client.BuildUri(request);
     if (request.Method != Method.POST &&
         request.Method != Method.PUT &&
         request.Method != Method.PATCH)
     {
         return uri;
     }
     else
     {
         var queryParameters = from p in request.Parameters
                               where p.Type == ParameterType.GetOrPost
                               select string.Format("{0}={1}", Uri.EscapeDataString(p.Name), Uri.EscapeDataString(p.Value.ToString()));
         if (!queryParameters.Any())
         {
             return uri;
         }
         else
         {
             var path = uri.OriginalString.TrimEnd('/');
             var query = string.Join("&", queryParameters);
             return new Uri(path + "?" + query);
         }
     }
 }
开发者ID:otint,项目名称:github-issues-via-feedback-form,代码行数:36,代码来源:RestSharpExts.cs

示例14: ApplyOptions

 private void ApplyOptions(IRestRequest request, bool isGet)
 {
     if (_asanaOptionsApplier != null)
     {
         _asanaOptionsApplier.ApplyOptions(request, true);
     }
 }
开发者ID:pocheptsov,项目名称:nasana,代码行数:7,代码来源:AsanaRequest.cs

示例15: LogRequest

        private void LogRequest(RestClient restClient, IRestRequest request, IRestResponse response, long durationMs)
        {
            var requestToLog = new
            {
                resource = request.Resource,
                // Parameters are custom anonymous objects in order to have the parameter type as a nice string
                // otherwise it will just show the enum value
                parameters = request.Parameters.Select(parameter => new
                {
                    name = parameter.Name,
                    value = parameter.Value,
                    type = parameter.Type.ToString()
                }),
                // ToString() here to have the method as a nice string otherwise it will just show the enum value
                method = request.Method.ToString(),
                // This will generate the actual Uri used in the request
                uri = restClient.BuildUri(request),
            };

            var responseToLog = new
            {
                statusCode = response.StatusCode,
                content = response.Content,
                headers = response.Headers,
                // The Uri that actually responded (could be different from the requestUri if a redirection occurred)
                responseUri = response.ResponseUri,
                errorMessage = response.ErrorMessage,
            };

            Trace.Write(string.Format("Request completed in {0} ms, Request: {1}, Response: {2}",
                    durationMs,
                    JsonConvert.SerializeObject(requestToLog),
                    JsonConvert.SerializeObject(responseToLog)));
        }
开发者ID:CactusSoft,项目名称:Cactus.Fileserver,代码行数:34,代码来源:CrudIntegrationTest.cs


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