HttpDateOrDeltaHeaderValue 類別

定義

表示 HTTP 回應上的 Retry-After HTTP 標頭值。

public ref class HttpDateOrDeltaHeaderValue sealed : 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 HttpDateOrDeltaHeaderValue final : 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 HttpDateOrDeltaHeaderValue : IStringable
Public NotInheritable Class HttpDateOrDeltaHeaderValue
Implements IStringable
繼承
Object Platform::Object IInspectable HttpDateOrDeltaHeaderValue
屬性
實作

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

下列範例程式碼示範使用 HttpDateOrDeltaHeaderValue 類別的屬性和方法,在HttpResponseMessage物件上取得和設定Retry-After HTTP 標頭的方法。

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

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

            // Set the header with a strong type.
            HttpDateOrDeltaHeaderValue newvalue;
            bool parseOk = HttpDateOrDeltaHeaderValue.TryParse("", out newvalue);
            if (parseOk) {
                response.Headers.RetryAfter = newvalue;
            }

            // Get the strong type out
            System.Diagnostics.Debug.WriteLine("Date value in ticks: {0}", response.Headers.Date.Value.Ticks);

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

備註

HttpDateOrDeltaHeaderValue 類別代表 HTTP 回應上的 Retry-After HTTP 標頭。

HttpResponseHeaderCollection上的RetryAfter屬性會傳回 HttpDateOrDeltaHeaderValue 物件。

屬性

Date

取得Retry-After HTTP 標頭中使用的HTTP 日期資訊值。

Delta

取得Retry-After HTTP 標頭中使用的差異秒資訊值。

方法

Parse(String)

將字串轉換為 HttpDateOrDeltaHeaderValue 實例。

ToString()

傳回字串,表示目前的 HttpDateOrDeltaHeaderValue 物件。

TryParse(String, HttpDateOrDeltaHeaderValue)

判斷字串是否為有效的 HttpDateOrDeltaHeaderValue 資訊。

適用於

另請參閱