語言

WebBaseEvent.FormatCustomEventDetails(WebEventFormatter) 方法

定義

提供活動資訊的標準格式。

public:
 virtual void FormatCustomEventDetails(System::Web::Management::WebEventFormatter ^ formatter);
public virtual void FormatCustomEventDetails(System.Web.Management.WebEventFormatter formatter);
abstract member FormatCustomEventDetails : System.Web.Management.WebEventFormatter -> unit
override this.FormatCustomEventDetails : System.Web.Management.WebEventFormatter -> unit
Public Overridable Sub FormatCustomEventDetails (formatter As WebEventFormatter)

參數

formatter
WebEventFormatter

一個 WebEventFormatter 包含格式化事件資訊的物件。

範例

以下程式碼範例展示了如何自訂此 FormatCustomEventDetails 方法。

//Formats Web request event information.
public override void FormatCustomEventDetails(
    WebEventFormatter formatter)
{
    base.FormatCustomEventDetails(formatter);

    // Add custom data.
    formatter.AppendLine("");

    formatter.IndentationLevel += 1;

    formatter.TabSize = 4;

    formatter.AppendLine(
         "*SampleWebBaseEvent Start *");

    // Display custom event information.
    formatter.AppendLine(customCreatedMsg);
    formatter.AppendLine(customRaisedMsg);
    formatter.AppendLine(firingRecordInfo);

    formatter.AppendLine(
  "* SampleWebBaseEvent End *");


    formatter.IndentationLevel -= 1;
}
    'Formats Web request event information.
    Public Overrides Sub FormatCustomEventDetails( _
ByVal formatter As WebEventFormatter)
        MyBase.FormatCustomEventDetails(formatter)

        ' Add custom data.
        formatter.AppendLine("")

        formatter.IndentationLevel += 1
        
        formatter.TabSize = 4
        
        formatter.AppendLine("*SampleWebBaseEvent Start *")
        formatter.AppendLine("Custom information goes here")
        formatter.AppendLine("* SampleWebBaseEvent End *")
        ' Display custom event timing.
        formatter.AppendLine(customCreatedMsg)
        formatter.AppendLine(customRaisedMsg)
        formatter.IndentationLevel -= 1

    End Sub

備註

此 FormatCustomEventDetails 方法提供事件資訊統一格式,若事件資料必須被記錄並稍後呈現給使用者,這非常有用。 當提供者呼叫其中一個 ToString 方法時,內部會呼叫它。

Note

當你格式化自訂事件資訊以顯示時,請覆蓋方法本身 FormatCustomEventDetails ,而不是方法本身 ToString 。 這樣可以避免覆蓋或竄改敏感系統資訊。

適用於