HttpCacheDirectiveHeaderValueCollection 클래스

정의

HTTP 요청 또는 응답과 연결된 HTTP 콘텐츠의 Cache-Control HTTP 헤더 값을 나타냅니다.

public ref class HttpCacheDirectiveHeaderValueCollection sealed : IIterable<HttpNameValueHeaderValue ^>, IVector<HttpNameValueHeaderValue ^>, 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 HttpCacheDirectiveHeaderValueCollection final : IIterable<HttpNameValueHeaderValue>, IVector<HttpNameValueHeaderValue>, IStringable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class HttpCacheDirectiveHeaderValueCollection final : IIterable<HttpNameValueHeaderValue>, IVector<HttpNameValueHeaderValue>, 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 HttpCacheDirectiveHeaderValueCollection : IEnumerable<HttpNameValueHeaderValue>, IList<HttpNameValueHeaderValue>, IStringable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class HttpCacheDirectiveHeaderValueCollection : IEnumerable<HttpNameValueHeaderValue>, IList<HttpNameValueHeaderValue>, IStringable
Public NotInheritable Class HttpCacheDirectiveHeaderValueCollection
Implements IEnumerable(Of HttpNameValueHeaderValue), IList(Of HttpNameValueHeaderValue), IStringable
상속
Object Platform::Object IInspectable HttpCacheDirectiveHeaderValueCollection
특성
구현

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

다음 샘플 코드에서는 HttpCacheDirectiveHeaderValueCollection 클래스의 속성과 메서드를 사용하여 HttpRequestMessage 개체에서 Cache-Control HTTP 헤더를 가져와서 설정하는 방법을 보여 줍니다.

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

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

            // Set the header with a string.
            parsedOk = request.Headers.CacheControl.TryParseAdd("no-store");

            // Set the header with a strong type.
            request.Headers.CacheControl.Add(new HttpNameValueHeaderValue("max-age", "10"));

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

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

다음 샘플 코드에서는 HttpCacheDirectiveHeaderValueCollection 클래스의 속성과 메서드를 사용하여 HttpResponseMessage 개체에서 Cache-Control HTTP 헤더를 가져와서 설정하는 방법을 보여 줍니다.

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

        public void DemonstrateHeaderResponseCacheControl() {
            var response = new HttpResponseMessage();

            // Set the header with a string
            response.Headers.CacheControl.TryParseAdd("public");

            // Set the header with a strong type
            response.Headers.CacheControl.Add(new HttpNameValueHeaderValue("max-age", "30"));

            // Get the strong type out
            foreach (var value in response.Headers.CacheControl) {
                System.Diagnostics.Debug.WriteLine("CacheControl {0}={1}", value.Name, value.Value);
            }

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

설명

HttpCacheDirectiveHeaderValueCollection 클래스는 HTTP 요청 또는 HTTP 응답과 연결된 HTTP 콘텐츠의 Cache-Control HTTP 헤더 값을 나타냅니다.

HttpRequestHeaderCollectionCacheControl 속성은 HttpCacheDirectiveHeaderValueCollection을 반환합니다. HttpResponseHeaderCollectionCacheControl 속성은 HttpCacheDirectiveHeaderValueCollection을 반환합니다.

컬렉션 멤버 목록

JavaScript의 경우 HttpCacheDirectiveHeaderValueCollection에는 멤버 목록에 표시된 멤버가 있습니다. 또한 HttpCacheDirectiveHeaderValueCollection은 Array.prototype 의 멤버를 지원하고 인덱스를 사용하여 항목에 액세스합니다.

C# 또는 Microsoft Visual Basic에서 컬렉션 열거

C# 또는 Microsoft Visual Basic에서 HttpCacheDirectiveHeaderValueCollection 개체를 반복할 수 있습니다. foreach 구문 사용과 같은 대부분의 경우 컴파일러는 이 캐스팅을 수행하므로 명시적으로 캐스팅 IEnumerable<HttpNameValueHeaderValue> 할 필요가 없습니다. 예를 들어 GetEnumerator를 호출하려는 경우 명시적으로 캐스팅해야 하는 경우 HttpNameValueHeaderValue 제약 조건을 사용하여 컬렉션 개체를 IEnumerable<T>로 캐스팅합니다.

속성

MaxAge

Cache-Control HTTP 헤더에서 max-age 지시문의 값을 가져오거나 설정합니다.

MaxStale

Cache-Control HTTP 헤더에서 max-stale 지시문의 값을 가져오거나 설정합니다.

MinFresh

Cache-Control HTTP 헤더에서 min-fresh 지시문의 값을 가져오거나 설정합니다.

SharedMaxAge

Cache-Control HTTP 헤더에서 s-maxage 지시문의 값을 가져오거나 설정합니다.

Size

컬렉션의 HttpNameValueHeaderValue 개체 수를 가져옵니다.

메서드

Append(HttpNameValueHeaderValue)

컬렉션의 끝에 새 HttpNameValueHeaderValue 항목을 추가합니다.

Clear()

컬렉션에서 모든 개체를 제거합니다.

First()

컬렉션의 첫 번째 HttpNameValueHeaderValue 항목에 대한 반복기를 검색합니다.

GetAt(UInt32)

컬렉션의 지정된 인덱스에서 HttpNameValueHeaderValue 를 반환합니다.

GetMany(UInt32, HttpNameValueHeaderValue[])

컬렉션의 지정된 인덱스에서 시작하는 HttpNameValueHeaderValue 항목을 검색합니다.

GetView()

HttpCacheDirectiveHeaderValueCollection의 변경할 수 없는 보기를 반환합니다.

IndexOf(HttpNameValueHeaderValue, UInt32)

컬렉션에서 HttpNameValueHeaderValue 의 인덱스를 검색합니다.

InsertAt(UInt32, HttpNameValueHeaderValue)

지정된 인덱스의 컬렉션에 HttpNameValueHeaderValue 를 삽입합니다.

ParseAdd(String)

HttpCacheDirectiveHeaderValueCollection에 항목을 구문 분석하고 추가합니다.

RemoveAt(UInt32)

HttpCacheDirectiveHeaderValueCollection에서 지정된 인덱스의 항목을 제거합니다.

RemoveAtEnd()

컬렉션에서 마지막 HttpNameValueHeaderValue 항목을 제거합니다.

ReplaceAll(HttpNameValueHeaderValue[])

컬렉션의 모든 HttpNameValueHeaderValue 항목을 지정된 HttpNameValueHeaderValue 항목으로 바꿉니다.

SetAt(UInt32, HttpNameValueHeaderValue)

컬렉션의 지정된 인덱스에서 HttpNameValueHeaderValue 를 설정합니다.

ToString()

현재 HttpCacheDirectiveHeaderValueCollection 개체를 나타내는 문자열을 반환합니다.

TryParseAdd(String)

HttpCacheDirectiveHeaderValueCollection에 지정된 항목을 구문 분석하고 추가하려고 시도합니다.

적용 대상

추가 정보