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


C# HttpRequestMessage.GetType方法代码示例

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


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

示例1: CanConvertFromStringReturnsFalseForHttpRequestMessage

 public void CanConvertFromStringReturnsFalseForHttpRequestMessage()
 {
     HttpRequestMessage request = new HttpRequestMessage<int>();
     HttpParameterValueConverter converter = HttpParameterValueConverter.GetValueConverter(request.GetType());
     if (converter.CanConvertFromString)
     {
         Assert.Fail(string.Format("CanConvertFromString was wrong for HttpRequestMessage."));
     }
 }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:9,代码来源:HttpParameterValueConverterTests.cs

示例2: WebApiUsageRequest

 /// <summary>
 /// Initializes a new instance of <see cref="WebApiUsageRequest"/>
 /// </summary>
 /// <param name="request"></param>
 public WebApiUsageRequest(HttpRequestMessage request)
 {
     if (request != null)
     {
         UsageType = request.GetType().Name;
         RequestMethod = request.Method.Method;
         Uri = request.RequestUri.ToString();
         IP = ((HttpContextBase)request.Properties["MS_HttpContext"]).Request.UserHostAddress;
         base.ExtractHeaders(request.Headers);
     }
     else
     {
         throw new ArgumentNullException("Request cannot be null");
     }
 }
开发者ID:Roblinde,项目名称:GSA-Web-api,代码行数:19,代码来源:WebApiUsage.cs

示例3: HttpRequestMessageFactory_AcceptsCustomDelegate

        public void HttpRequestMessageFactory_AcceptsCustomDelegate()
        {
            Configuration configuration = new Configuration(
                Environment.DEVELOPMENT,
                "integration_merchant_id",
                "integration_public_key",
                "integration_private_key"
            );

#if netcore
            configuration.HttpRequestMessageFactory =
                delegate (HttpMethod method, string requestUriString)
                {
                    HttpRequestMessage httpRequestMessage = new HttpRequestMessage(method, requestUriString);
                    httpRequestMessage.Headers.Range = new RangeHeaderValue(1024, 2048);
                    return httpRequestMessage;
                };
            Assert.IsNotNull(configuration.HttpRequestMessageFactory);

            var btWebRequest = configuration.HttpRequestMessageFactory(HttpMethod.Get, configuration.Environment.GatewayURL + "/merchants/integration_merchant_id");
            HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, "http://webrequest.com");

            Assert.IsInstanceOf(requestMessage.GetType(), btWebRequest);
            var headerValue = btWebRequest.Headers.Range;
            StringAssert.Contains("1024", btWebRequest.Headers.Range.ToString());
#else
            configuration.HttpWebRequestFactory =
                delegate(String requestUriString)
                {
                    var webRequest = WebRequest.Create(requestUriString) as HttpWebRequest;
                    webRequest.AddRange(1024);
                    return webRequest;
                };

            Assert.IsNotNull(configuration.HttpWebRequestFactory);

            var btWebRequest = configuration.HttpWebRequestFactory(configuration.Environment.GatewayURL + "/merchants/integration_merchant_id");
            HttpWebRequest httpWebRequest = WebRequest.Create("http://webrequest.com") as HttpWebRequest;
            
            Assert.IsInstanceOf(httpWebRequest.GetType(), btWebRequest);
            StringAssert.Contains("1024", btWebRequest.Headers["Range"]);
#endif
        }
开发者ID:braintree,项目名称:braintree_dotnet,代码行数:43,代码来源:ConfigurationTest.cs

示例4: HttpRequestMessageFactory_ReturnsDefaultIfNotSpecified

        public void HttpRequestMessageFactory_ReturnsDefaultIfNotSpecified()
        {
            Configuration configuration = new Configuration(
                Environment.DEVELOPMENT,
                "integration_merchant_id",
                "integration_public_key",
                "integration_private_key"
            );

#if netcore
            Assert.IsNotNull(configuration.HttpRequestMessageFactory);
            HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, "http://webrequest.com");
            Assert.IsInstanceOf(httpRequestMessage.GetType(), configuration.HttpRequestMessageFactory(HttpMethod.Get, configuration.Environment.GatewayURL + "/merchants/integration_merchant_id"));
#else
            Assert.IsNotNull(configuration.HttpWebRequestFactory);
            HttpWebRequest httpWebRequest = WebRequest.Create("http://webrequest.com") as HttpWebRequest;
            Assert.IsInstanceOf(httpWebRequest.GetType(), configuration.HttpWebRequestFactory(configuration.Environment.GatewayURL + "/merchants/integration_merchant_id"));
#endif
        }
开发者ID:braintree,项目名称:braintree_dotnet,代码行数:19,代码来源:ConfigurationTest.cs


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