本文整理汇总了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."));
}
}
示例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");
}
}
示例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
}
示例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
}