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


C# RequestInfo类代码示例

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


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

示例1: SetsContentNullIfBodyValueIsNull

 public void SetsContentNullIfBodyValueIsNull()
 {
     var requestInfo = new RequestInfo(HttpMethod.Get, "foo");
     requestInfo.SetBodyParameterInfo<object>(BodySerializationMethod.Serialized, null);
     var content = this.requester.ConstructContent(requestInfo);
     Assert.Null(content);
 }
开发者ID:modulexcite,项目名称:RestEase,代码行数:7,代码来源:ContentConstructionTests.cs

示例2: ConstructsUriWithEscapedGivenParams

 public void ConstructsUriWithEscapedGivenParams()
 {
     var requestInfo = new RequestInfo(HttpMethod.Get, null);
     requestInfo.AddQueryParameter(QuerySerializationMethod.ToString, "b ar", "b az");
     var uri = this.requester.ConstructUri("/foo", requestInfo);
     Assert.Equal(new Uri("http://api.example.com/base/foo?b+ar=b+az"), uri);
 }
开发者ID:modulexcite,项目名称:RestEase,代码行数:7,代码来源:UriConstructionTests.cs

示例3: Request

        public override void Request(RequestLocalOptions opt, Message req, Action<Message> on_rpy)
        {
            string id;
            string is_closed;
            lock (state_lock) {
                id = (nextid++).ToString ();
                is_closed = closed_err;
                if (is_closed == null) {
                    pending [id] = new RequestInfo {
                        cb = on_rpy,
                        timeout = new Timer ((s) => {
                            RequestTimedOut (id);
                        }, null, (opt.Timeout + 5) * 1000, Timeout.Infinite),
                    };
                }
            }

            if (is_closed != null) {
                req.Discard ();
                Message.StreamToCallback (on_rpy, new RPCException ("transport", "Connection is closed", RPCException.DispatchFailure ()).AsHeader ());
            } else {
                req.Header ["request_id"] = id;
                req.Header ["type"] = "request";
                p.SendMessage (req);
            }
        }
开发者ID:dnorman,项目名称:scamp,代码行数:26,代码来源:SCAMPSOAClient.cs

示例4: HeadersFromPropertiesCombineWithHeadersFromClass

        public void HeadersFromPropertiesCombineWithHeadersFromClass()
        {
            var requestInfo = new RequestInfo(HttpMethod.Get, "foo");
            requestInfo.ClassHeaders = new List<KeyValuePair<string, string>>()
            {
                new KeyValuePair<string, string>("This-Will-Stay", "YesIWill"),
                new KeyValuePair<string, string>("Something", "SomethingElse"),
                new KeyValuePair<string, string>("User-Agent", "RestEase"),
                new KeyValuePair<string, string>("X-API-Key", "Foo"),
            };

            requestInfo.AddPropertyHeader<string>("Something", null, null);
            requestInfo.AddPropertyHeader("User-Agent", String.Empty, null);
            requestInfo.AddPropertyHeader("X-API-Key", "Bar", null);
            requestInfo.AddPropertyHeader("This-Is-New", "YesIAm", null);

            var message = new HttpRequestMessage();
            this.requester.ApplyHeaders(requestInfo, message);

            Assert.Equal(new[] { "YesIWill" }, message.Headers.GetValues("This-Will-Stay"));
            Assert.Equal(new[] { "SomethingElse" }, message.Headers.GetValues("Something"));
            Assert.Equal(new[] { "RestEase", "" }, message.Headers.GetValues("User-Agent"));
            Assert.Equal(new[] { "Foo", "Bar" }, message.Headers.GetValues("X-API-Key"));
            Assert.Equal(new[] { "YesIAm" }, message.Headers.GetValues("This-Is-New"));
        }
开发者ID:modulexcite,项目名称:RestEase,代码行数:25,代码来源:HeadersTests.cs

示例5: RequestAsyncSendsRequest

        public void RequestAsyncSendsRequest()
        {
            var requester = new RequesterWithStubbedSendRequestAsync(null);
            var responseMessage = new HttpResponseMessage()
            {
                Content = new StringContent("content"),
            };
            requester.ResponseMessage = Task.FromResult(responseMessage);
            var responseDeserializer = new Mock<IResponseDeserializer>();
            requester.ResponseDeserializer = responseDeserializer.Object;
            var cancellationToken = new CancellationToken();

            responseDeserializer.Setup(x => x.Deserialize<string>("content", responseMessage))
                .Returns("hello")
                .Verifiable();

            var requestInfo = new RequestInfo(HttpMethod.Get, "foo");
            requestInfo.CancellationToken = cancellationToken;
            var result = requester.RequestAsync<string>(requestInfo).Result;

            responseDeserializer.Verify();

            Assert.Equal(requestInfo, requester.RequestInfo);
            Assert.Equal("hello", result);
        }
开发者ID:modulexcite,项目名称:RestEase,代码行数:25,代码来源:SendRequestTests.cs

示例6: Get

 public HttpResponseMessage Get()
 {
     string dsName = (string)Request.Properties[Constants.ODataDataSource];
     var ds = DataSourceProvider.GetDataSource(dsName);
     var options = BuildQueryOptions();
     EdmEntityObjectCollection rtv = null;
     if (DynamicOData.BeforeExcute != null)
     {
         var ri = new RequestInfo(dsName)
         {
             Method = MethodType.Get,
             QueryOptions = options,
             Target = options.Context.Path.Segments[0].ToString()
         };
         DynamicOData.BeforeExcute(ri);
         if (!ri.Result)
             return Request.CreateResponse(ri.StatusCode, ri.Message);
     }
     try
     {
         rtv = ds.Get(options);
         if (options.SelectExpand != null)
             Request.ODataProperties().SelectExpandClause = options.SelectExpand.SelectExpandClause;
         return Request.CreateResponse(HttpStatusCode.OK, rtv);
     }
     catch (UnauthorizedAccessException ex)
     {
         return Request.CreateErrorResponse(HttpStatusCode.Unauthorized, ex);
     }
     catch (Exception err)
     {
         return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, err);
     }
 }
开发者ID:maskx,项目名称:OData,代码行数:34,代码来源:DynamicODataController.cs

示例7: GNTPParserTest

 public void GNTPParserTest()
 {
     var pw = new PasswordManager();
     var info = new RequestInfo();
     var parser = new GNTPParser(pw, false, true, true, true, info);
     var items = new List<IGNTPRequest>();
     parser.MessageParsed += (req) =>
     {
         items.Add(req);
     };
     parser.Error += (error) =>
     {
         Assert.Fail("ErrorCode={0}, Description={1}", error.ErrorCode, error.ErrorDescription);
     };
     ParseAll(parser);
     Assert.IsTrue(items.Count > 0);
     foreach (var item in items) {
         if (item.Directive == RequestType.NOTIFY) {
             var nLog = NeithNotificationRec.FromHeaders(item.Headers);
         }
         if (item.Directive == RequestType.REGISTER) {
             var app = Application.FromHeaders(item.Headers);
             Assert.AreEqual("SurfWriter", app.Name);
         }
     }
 }
开发者ID:pudwinkie,项目名称:neith,代码行数:26,代码来源:ParseTest.cs

示例8: EncodesPathParams

 public void EncodesPathParams()
 {
     var requestInfo = new RequestInfo(HttpMethod.Get, "/foo/{bar}/baz");
     requestInfo.AddPathParameter<string>("bar", "a/b/c");
     var uri = this.requester.SubstitutePathParameters(requestInfo);
     Assert.Equal("/foo/a%2fb%2fc/baz", uri);
 }
开发者ID:modulexcite,项目名称:RestEase,代码行数:7,代码来源:PathParameterTests.cs

示例9: Delete

 public HttpResponseMessage Delete(string key)
 {
     var path = Request.ODataProperties().Path;
     var edmType = path.Segments[0].GetEdmType(path.EdmType);
     string dsName = (string)Request.Properties[Constants.ODataDataSource];
     var ds = DataSourceProvider.GetDataSource(dsName);
     if (DynamicOData.BeforeExcute != null)
     {
         var ri = new RequestInfo(dsName)
         {
             Method = MethodType.Delete,
             Target = (edmType as EdmEntityType).Name
         };
         DynamicOData.BeforeExcute(ri);
         if (!ri.Result)
             return Request.CreateResponse(ri.StatusCode, ri.Message);
     }
     try
     {
         var count = ds.Delete(key, edmType);
         return Request.CreateResponse(HttpStatusCode.OK, count);
     }
     catch (UnauthorizedAccessException ex)
     {
         return Request.CreateErrorResponse(HttpStatusCode.Unauthorized, ex);
     }
     catch (Exception err)
     {
         return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, err);
     }
 }
开发者ID:maskx,项目名称:OData,代码行数:31,代码来源:DynamicODataController.cs

示例10: ArgumentBindingContext

        internal ArgumentBindingContext(RequestInfo request, RequestMapping requestMapping, ParameterInfo parameter, int index, IDictionary<RequestInfo, RequestInfo[]> multipartBodies)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            if (requestMapping == null)
            {
                throw new ArgumentNullException("requestMapping");
            }

            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            if (multipartBodies == null)
            {
                throw new ArgumentNullException("multipartBodies");
            }

            Request = request;
            RequestMapping = requestMapping;
            Parameter = parameter;
            Index = index;
            MultipartBodies = multipartBodies;
        }
开发者ID:alien-mcl,项目名称:URSA,代码行数:28,代码来源:ArgumentBindingContext.cs

示例11: Cache

        public void Cache(RequestInfo requestInfo, string answer)
        {
            HashAnswer hashAnswer = new HashAnswer();
            hashAnswer.Answer = answer;
            hashAnswer.QuestionText = requestInfo.Data;

            var firstOrDefault = work.HandlerTypes.GetAll().FirstOrDefault(
                x => x.Name == requestInfo.HandlerName);

            if (firstOrDefault != null)
            {
                hashAnswer.HandlerTypeId = firstOrDefault.Id;
            }
            else
            {
                // Create handler type if note exists
                HandlerType handler = new HandlerType()
                {
                    Name = requestInfo.HandlerName
                };
                work.HandlerTypes.Create(handler);
                work.Save();
                hashAnswer.HandlerTypeId =
                    work.HandlerTypes.GetAll().First(x => x.Name == requestInfo.HandlerName).Id;
            }

            work.HashAnswers.Create(hashAnswer);
            work.Save();
        }
开发者ID:TarasKanf,项目名称:IntegralEquationProject,代码行数:29,代码来源:CachingService.cs

示例12: IgnoresNullQueryParamArrayValuesWhenUsingToString

 public void IgnoresNullQueryParamArrayValuesWhenUsingToString()
 {
     var requestInfo = new RequestInfo(HttpMethod.Get, null);
     requestInfo.AddQueryCollectionParameter<object>(QuerySerializationMethod.ToString, "foo", new[] { "bar", null, "baz" });
     var uri = this.requester.ConstructUri("/foo", requestInfo);
     Assert.Equal(new Uri("http://api.example.com/base/foo?foo=bar&foo=baz"), uri);
 }
开发者ID:modulexcite,项目名称:RestEase,代码行数:7,代码来源:QueryParameterTests.cs

示例13: Execute

 public HttpResponse Execute(RequestInfo req)
 {
     var o = Activator.CreateInstance(_mi.DeclaringType);
     var prms = new object[_binders.Length];
     for(var i = 0 ; i<_binders.Length ; ++i)
     {
         prms[i] = _binders[i](req);
     }
     try
     {
         return _mi.Invoke(o, prms) as HttpResponse;
     }
     catch (TargetInvocationException e)
     {
         throw e.InnerException;
     }
     catch(ArgumentException e)
     {
         return new HttpResponse(HttpStatusCode.BadRequest, new TextContent(e.Message));
     }
     catch(InvalidOperationException e)
     {
         return new HttpResponse(HttpStatusCode.InternalServerError, new TextContent(e.Message));
     }
 }
开发者ID:LuisLoureiro,项目名称:isel-leic-pi-1112si,代码行数:25,代码来源:MethodBasedCommand.cs

示例14: SetsContentNullIfBodyParameterInfoNull

 public void SetsContentNullIfBodyParameterInfoNull()
 {
     var requestInfo = new RequestInfo(HttpMethod.Get, "foo");
     // Not calling SetBodyParameterInfo
     var content = this.requester.ConstructContent(requestInfo);
     Assert.Null(content);
 }
开发者ID:modulexcite,项目名称:RestEase,代码行数:7,代码来源:ContentConstructionTests.cs

示例15: AddRequestInfo

        /// <summary>
        /// Adds the request info to the event.
        /// </summary>
        public static void AddRequestInfo(this Event ev, RequestInfo request)
        {
            if (request == null)
                return;

            ev.Data[Event.KnownDataKeys.RequestInfo] = request;
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:10,代码来源:EventExtensions.cs


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