HttpContentCodingWithQualityHeaderValueCollection 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示 HTTP 请求上的 Accept-Encoding HTTP 标头的值。
public ref class HttpContentCodingWithQualityHeaderValueCollection sealed : IIterable<HttpContentCodingWithQualityHeaderValue ^>, IVector<HttpContentCodingWithQualityHeaderValue ^>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class HttpContentCodingWithQualityHeaderValueCollection final : IIterable<HttpContentCodingWithQualityHeaderValue>, IVector<HttpContentCodingWithQualityHeaderValue>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class HttpContentCodingWithQualityHeaderValueCollection final : IIterable<HttpContentCodingWithQualityHeaderValue>, IVector<HttpContentCodingWithQualityHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class HttpContentCodingWithQualityHeaderValueCollection : IEnumerable<HttpContentCodingWithQualityHeaderValue>, IList<HttpContentCodingWithQualityHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class HttpContentCodingWithQualityHeaderValueCollection : IEnumerable<HttpContentCodingWithQualityHeaderValue>, IList<HttpContentCodingWithQualityHeaderValue>, IStringable
Public NotInheritable Class HttpContentCodingWithQualityHeaderValueCollection
Implements IEnumerable(Of HttpContentCodingWithQualityHeaderValue), IList(Of HttpContentCodingWithQualityHeaderValue), IStringable
- 继承
- 属性
- 实现
Windows 要求
设备系列 |
Windows 10 (在 10.0.10240.0 中引入)
|
API contract |
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)
|
示例
以下示例代码演示了一个方法,该方法使用 HttpContentCodingWithQualityHeaderValueCollection 和 HttpContentCodingWithQualityHeaderValue 类的属性和方法在 HttpRequestMessage 对象上获取和设置 Accept-Encoding HTTP 标头。
using Windows.Web.Http;
using Windows.Web.Http.Headers;
public void DemonstrateHeaderRequestAcceptEncoding()
{
var request = new HttpRequestMessage();
bool parsedOk = false;
// Set the header with a string.
parsedOk = request.Headers.AcceptEncoding.TryParseAdd("compress");
parsedOk = request.Headers.AcceptEncoding.TryParseAdd("gzip;q=1.0");
// Set the header with a strong type.
request.Headers.AcceptEncoding.Add(new HttpContentCodingWithQualityHeaderValue("*", 0));
// Get the strong type out
foreach (var value in request.Headers.AcceptEncoding)
{
System.Diagnostics.Debug.WriteLine("One of the AcceptEncoding values: {0}={1}", value.ContentCoding, value.Quality);
}
// The ToString() is useful for diagnostics, too.
System.Diagnostics.Debug.WriteLine("The AcceptEncoding ToString() results: {0}", request.Headers.AcceptEncoding.ToString());
}
注解
HttpContentCodingWithQualityHeaderValueCollection 类表示 HTTP 请求上的 Accept-Encoding HTTP 标头的值。
HttpContentCodingWithQualityHeaderValueCollection 为 HttpContentCodingWithQualityHeaderValue 类的实例提供集合容器,该类用于接受 编码 HTTP 标头中的编码信息。
HttpRequestHeaderCollection 上的 AcceptEncoding 属性返回 HttpContentCodingWithQualityHeaderValueCollection 对象。 这是用于构造 HttpContentCodingWithQualityHeaderValueCollection 对象的方法。
集合成员列表
对于 JavaScript,HttpContentCodingWithQualityHeaderValueCollection 的成员显示在成员列表中。 此外,HttpContentCodingWithQualityHeaderValueCollection 支持 Array.prototype 的成员,并使用索引访问项。
枚举 C# 或 Microsoft Visual Basic 中的集合
可以在 C# 或 Microsoft Visual Basic 中循环访问 HttpContentCodingWithQualityHeaderValueCollection 对象。 在许多情况下,例如使用 foreach 语法,编译器会为你执行此强制转换,你无需显式强制转换为 IEnumerable<HttpContentCodingWithQualityHeaderValue>
。 如果需要显式强制转换(例如,如果要调用 GetEnumerator),请使用 HttpContentCodingWithQualityHeaderValue 约束将集合对象强制转换为 IEnumerable<T>。
属性
Size |
获取集合中 HttpContentCodingWithQualityHeaderValue 对象的数目。 |