Share via


MsnNotificationClass.GetSerialization メソッド

MsnNotificationClass

このメソッドは、MsnNotificationClass オブジェクトを XML にシリアル化し、文字列として返します。

定義

public virtual System.String GetSerialization()

戻り値

MsnNotificationClass オブジェクトの XML 表現が含まれる文字列を返します。

次の例は、GetSerialization メソッドの使い方を示しています。

static void DemoGetSerialization(MsnNotificationClass Alert) {
    
    try {
        String xmlString;

        // Initialize the alert, but not the destination PUID.
        Alert.ID = "12345";
        Alert.ToPID = "";
        Alert.MessageID = "0";
        Alert.Priority = "1";
        Alert.SiteURL = "https://www.adventure-works.com";
        Alert.ActionURL = "/action.asp?ID=" + Alert.ID;
        Alert.SubscribeURL = "/subscr.asp";
        Alert.BodyIcon = "/aw_logo.png";
        Alert.BodyLanguage = "1033";
        Alert.Body = "Your Adventure Works order has been shipped!";

        xmlString = Alert.GetSerialization();
        Console.WriteLine(xmlString);
    }

    catch (COMException hr) { // Non-COM exceptions will propagate to Main().   
        Console.WriteLine("A COM error occurred while demonstrating GetSerialization: 0x{0} {1}",
            hr.ErrorCode.ToString("x"),
            hr.Message);
    }

} // End DemoGetSerialization.

GetSerialization の呼び出しが完了すると、xmlString には次のような情報が格納されます。

<NOTIFICATION ver="1" id="12345" siteid="114001000" siteurl="https://www.adventure-works.com" >
    <TO pid="0x01234567:0x89abcdef" />
    <MSG id="0" pri="1" >
        <ACTION url="/action.asp" />
        <SUBSCR url="/subscribe.asp" />
        <BODY lang="1033" icon="/aw_toast_logo.png" >
            <TEXT>Your Adventure Works order has been shipped!</TEXT>
        </BODY>
    </MSG>
</NOTIFICATION>

解説

このメソッドを使用すると、診断の目的で通知オブジェクトの内容を調べることができます。

関連項目

C# リファレンスの概要

  |