本文整理汇总了C#中System.Net.Http.Headers.MediaTypeHeaderValue.IsWithinMediaRange方法的典型用法代码示例。如果您正苦于以下问题:C# MediaTypeHeaderValue.IsWithinMediaRange方法的具体用法?C# MediaTypeHeaderValue.IsWithinMediaRange怎么用?C# MediaTypeHeaderValue.IsWithinMediaRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Http.Headers.MediaTypeHeaderValue
的用法示例。
在下文中一共展示了MediaTypeHeaderValue.IsWithinMediaRange方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsWithinMediaRange_Returns_False_When_Charset_Is_Different
public void IsWithinMediaRange_Returns_False_When_Charset_Is_Different()
{
MediaTypeHeaderValue mediaRange = new MediaTypeHeaderValue("application/xml");
MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("application/xml");
mediaType.CharSet = "US-ASCII";
mediaRange.CharSet = "OtherCharSet";
Assert.IsFalse(mediaType.IsWithinMediaRange(mediaRange), "MediaTypeHeadeValueExtensionMethods.IsWithinMediaRange should have returned false because of the different charsets.");
}
示例2: IsWithinMediaRange_Returns_True_For_Media_Ranges
public void IsWithinMediaRange_Returns_True_For_Media_Ranges()
{
MediaTypeHeaderValue mediaRange = new MediaTypeHeaderValue("text/*");
MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("text/xml");
Assert.IsTrue(mediaType.IsWithinMediaRange(mediaRange), "MediaTypeHeadeValueExtensionMethods.IsWithinMediaRange should have returned true for 'text/*'.");
mediaRange = new MediaTypeHeaderValue("*/*");
Assert.IsTrue(mediaType.IsWithinMediaRange(mediaRange), "MediaTypeHeadeValueExtensionMethods.IsWithinMediaRange should have returned true for '*/*'.");
}
示例3: IsWithinMediaRange_Returns_False_When_Type_Is_Different
public void IsWithinMediaRange_Returns_False_When_Type_Is_Different()
{
MediaTypeHeaderValue mediaRange = new MediaTypeHeaderValue("text/*");
MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("application/xml");
Assert.IsFalse(mediaType.IsWithinMediaRange(mediaRange), "MediaTypeHeadeValueExtensionMethods.IsWithinMediaRange should have returned false for 'text/*' because the media type is 'application/xml'.");
}
示例4: IsWithinMediaRange_Returns_False_When_SubType_Is_Different
public void IsWithinMediaRange_Returns_False_When_SubType_Is_Different()
{
MediaTypeHeaderValue mediaRange = new MediaTypeHeaderValue("application/json");
MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("application/xml");
Assert.IsFalse(mediaType.IsWithinMediaRange(mediaRange), "MediaTypeHeadeValueExtensionMethods.IsWithinMediaRange should have returned false because of the different sub types.");
}
示例5: IsWithinMediaRange_Returns_True_Regardless_Of_Media_Ranges_With_Charset
public void IsWithinMediaRange_Returns_True_Regardless_Of_Media_Ranges_With_Charset()
{
MediaTypeHeaderValue mediaRange = new MediaTypeHeaderValue("text/*");
MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("text/xml");
mediaRange.CharSet = "US-ASCII";
Assert.IsTrue(mediaType.IsWithinMediaRange(mediaRange), "MediaTypeHeadeValueExtensionMethods.IsWithinMediaRange should have returned true for 'text/*' even if the media range has a charset.");
}
示例6: IsWithinMediaRange_Returns_True_For_Media_Types_With_Charset_And_Media_Ranges_With_Same_Charset
public void IsWithinMediaRange_Returns_True_For_Media_Types_With_Charset_And_Media_Ranges_With_Same_Charset()
{
MediaTypeHeaderValue mediaRange = new MediaTypeHeaderValue("text/*");
MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("text/xml");
mediaType.CharSet = "US-ASCII";
mediaRange.CharSet = "US-ASCII";
Assert.IsTrue(mediaType.IsWithinMediaRange(mediaRange), "MediaTypeHeadeValueExtensionMethods.IsWithinMediaRange should have returned true for 'text/*'.");
}
示例7: IsWithinMediaRange_Returns_True_For_Media_Types_Equaivalent_To_The_Media_Range
public void IsWithinMediaRange_Returns_True_For_Media_Types_Equaivalent_To_The_Media_Range()
{
MediaTypeHeaderValue mediaRange = new MediaTypeHeaderValue("application/xml");
MediaTypeHeaderValue mediaType = new MediaTypeHeaderValue("application/xml");
Assert.IsTrue(mediaType.IsWithinMediaRange(mediaRange), "MediaTypeHeadeValueExtensionMethods.IsWithinMediaRange should have returned true for 'application/xml'.");
}