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