HttpLanguageRangeWithQualityHeaderValueCollection 类

定义

表示 HTTP 请求上的 Accept-Language HTTP 标头的值。

public ref class HttpLanguageRangeWithQualityHeaderValueCollection sealed : IIterable<HttpLanguageRangeWithQualityHeaderValue ^>, IVector<HttpLanguageRangeWithQualityHeaderValue ^>, 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 HttpLanguageRangeWithQualityHeaderValueCollection final : IIterable<HttpLanguageRangeWithQualityHeaderValue>, IVector<HttpLanguageRangeWithQualityHeaderValue>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class HttpLanguageRangeWithQualityHeaderValueCollection final : IIterable<HttpLanguageRangeWithQualityHeaderValue>, IVector<HttpLanguageRangeWithQualityHeaderValue>, 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 HttpLanguageRangeWithQualityHeaderValueCollection : IEnumerable<HttpLanguageRangeWithQualityHeaderValue>, IList<HttpLanguageRangeWithQualityHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class HttpLanguageRangeWithQualityHeaderValueCollection : IEnumerable<HttpLanguageRangeWithQualityHeaderValue>, IList<HttpLanguageRangeWithQualityHeaderValue>, IStringable
Public NotInheritable Class HttpLanguageRangeWithQualityHeaderValueCollection
Implements IEnumerable(Of HttpLanguageRangeWithQualityHeaderValue), IList(Of HttpLanguageRangeWithQualityHeaderValue), IStringable
继承
Object Platform::Object IInspectable HttpLanguageRangeWithQualityHeaderValueCollection
属性
实现

Windows 要求

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

示例

下面的示例代码演示了一个方法,该方法使用 HttpLanguageRangeWithQualityHeaderValueCollection 和 HttpLanguageRangeWithQualityHeaderValue 类的属性和方法获取和设置 HttpRequestMessage 对象上的 Accept-LanguageHTTP 标头。

using System;
using Windows.Web.Http;
using Windows.Web.Http.Headers;

        public void DemonstrateHeaderRequestAcceptLanguage() {
            var request = new HttpRequestMessage();
            bool parsedOk = false;

            // Set the header with a string.
            parsedOk = request.Headers.AcceptLanguage.TryParseAdd("da");
            parsedOk = request.Headers.AcceptLanguage.TryParseAdd("en-gb;q=0.8");

            // Set the header with a strong type.
            request.Headers.AcceptLanguage.Add(new HttpLanguageRangeWithQualityHeaderValue("en", .7));

            // Get the strong type out
            foreach (var value in request.Headers.AcceptLanguage) {
                System.Diagnostics.Debug.WriteLine("One of the AcceptLanguage values: {0}={1}", value.LanguageRange, value.Quality);
            }

            // The ToString() is useful for diagnostics, too.
            System.Diagnostics.Debug.WriteLine("The AcceptLanguage ToString() results: {0}", request.Headers.AcceptLanguage.ToString());
        }

注解

HttpLanguageRangeWithQualityHeaderValueCollection 类表示 HTTP 请求上的 Accept-Language HTTP 标头的值。

HttpLanguageRangeWithQualityHeaderValueCollection 为 HttpLanguageRangeWithQualityHeaderValue 类的实例提供一个集合容器,该类用于接受 Accept-Language HTTP 标头中的语言信息。

HttpRequestHeaderCollection 上的 AcceptLanguage 属性返回 HttpLanguageRangeWithQualityHeaderValueCollection 对象。

属性

Size

获取集合中 HttpLanguageRangeWithQualityHeaderValue 对象的数目。

方法

Append(HttpLanguageRangeWithQualityHeaderValue)

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

Clear()

从集合中删除所有对象。

First()

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

GetAt(UInt32)

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

GetMany(UInt32, HttpLanguageRangeWithQualityHeaderValue[])

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

GetView()

返回 HttpLanguageRangeWithQualityHeaderValueCollection 的不可变视图。

IndexOf(HttpLanguageRangeWithQualityHeaderValue, UInt32)

检索集合中 HttpLanguageRangeWithQualityHeaderValue 的索引。

InsertAt(UInt32, HttpLanguageRangeWithQualityHeaderValue)

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

ParseAdd(String)

分析 HttpLanguageRangeWithQualityHeaderValueCollection 并添加一个条目。

RemoveAt(UInt32)

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

RemoveAtEnd()

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

ReplaceAll(HttpLanguageRangeWithQualityHeaderValue[])

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

SetAt(UInt32, HttpLanguageRangeWithQualityHeaderValue)

设置集合中指定索引处的 HttpLanguageRangeWithQualityHeaderValue

ToString()

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

TryParseAdd(String)

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

适用于

另请参阅