共用方式為


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 引進)

範例

下列範例程式碼示範方法,使用HttpContentCodingWithQualityHeaderValueCollection 和 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 類別的集合容器,用於接受 Accept-Encoding 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

適用於

另請參閱