HttpContentCodingWithQualityHeaderValueCollection 类

定义

表示 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
继承
Object Platform::Object IInspectable HttpContentCodingWithQualityHeaderValueCollection
属性
实现

Windows 要求

设备系列
Windows 10 (在 10.0.10240.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)

示例

以下示例代码演示了一个方法,该方法使用 HttpContentCodingWithQualityHeaderValueCollectionHttpContentCodingWithQualityHeaderValue 类的属性和方法在 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 对象的数目。

方法

Append(HttpContentCodingWithQualityHeaderValue)

将新的 HttpContentCodingWithQualityHeaderValue 项添加到集合的末尾。

Clear()

从集合中删除所有对象。

First()

检索集合中第一个 HttpContentCodingWithQualityHeaderValue 项的迭代器。

GetAt(UInt32)

返回集合中指定索引处的 HttpContentCodingWithQualityHeaderValue

GetMany(UInt32, HttpContentCodingWithQualityHeaderValue[])

检索从集合中的指定索引处开始的 HttpContentCodingWithQualityHeaderValue 项。

GetView()

返回 HttpContentCodingWithQualityHeaderValueCollection 的不可变视图。

IndexOf(HttpContentCodingWithQualityHeaderValue, UInt32)

检索集合中 HttpContentCodingWithQualityHeaderValue 的索引。

InsertAt(UInt32, HttpContentCodingWithQualityHeaderValue)

HttpContentCodingWithQualityHeaderValue 插入集合中的指定索引处。

ParseAdd(String)

分析 HttpContentCodingWithQualityHeaderValueCollection 并添加一个条目。

RemoveAt(UInt32)

HttpContentCodingWithQualityHeaderValueCollection 中删除指定索引处的条目。

RemoveAtEnd()

从集合中删除最后一个 HttpContentCodingWithQualityHeaderValue 项。

ReplaceAll(HttpContentCodingWithQualityHeaderValue[])

将集合中的所有 HttpContentCodingWithQualityHeaderValue 项替换为指定的 HttpContentCodingWithQualityHeaderValue 项。

SetAt(UInt32, HttpContentCodingWithQualityHeaderValue)

在集合中的指定索引处设置 HttpContentCodingWithQualityHeaderValue

ToString()

返回表示当前 HttpContentCodingWithQualityHeaderValueCollection 对象的字符串。

TryParseAdd(String)

尝试分析指定的项并将其添加到 HttpContentCodingWithQualityHeaderValueCollection

适用于

另请参阅