WebAccountProviderRetrieveCookiesOperation 類別

定義

表示 Web 帳戶提供者所做的擷取 Cookie 作業。

public ref class WebAccountProviderRetrieveCookiesOperation sealed : IWebAccountProviderBaseReportOperation
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class WebAccountProviderRetrieveCookiesOperation final : IWebAccountProviderBaseReportOperation
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class WebAccountProviderRetrieveCookiesOperation : IWebAccountProviderBaseReportOperation
Public NotInheritable Class WebAccountProviderRetrieveCookiesOperation
Implements IWebAccountProviderBaseReportOperation
繼承
Object Platform::Object IInspectable WebAccountProviderRetrieveCookiesOperation
屬性
實作

Windows 需求

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

範例

下列示範如何處理擷取 Cookie 作業:

void HandleRetrieveCookies(WebAccountProviderRetrieveCookiesOperation operation)
{
    try
    {
        // Parse the Uri to retrieve context information
        Uri myUri = ParseMyUri(operation.Context);

        // Do custom logic based on the context
        // INSERT LOGIC HERE

        // Get the HttpCookieCollection for the Uri
        HttpBaseProtocolFilter filt = new HttpBaseProtocolFilter();
        HttpCookieCollection cookies = filt.CookieManager.GetCookies(myUri);
        foreach (HttpCookie cookie in cookies)
        {
            operation.Cookies.Add(cookie);
        }
        operation.ReportCompleted();
    }
    catch (Exception ex)
    {
        WebProviderError error = new WebProviderError(ERROR_CODE_FOO, ex.Message);
        operation.ReportError(error); 
    }
}

屬性

ApplicationCallbackUri

取得應用程式回呼 URI。

Context

取得擷取 Cookie 作業的內容。

Cookies

取得 Cookie。

Kind

取得 Web 帳戶提供者作業的類型。

Uri

取得或設定要從中擷取 Cookie 的 Uri。

方法

ReportCompleted()

通知啟動的應用程式作業已順利完成。

ReportError(WebProviderError)

通知啟動應用程式作業發生錯誤。

適用於

另請參閱