BodyWriter.OnWriteBodyContents(XmlDictionaryWriter) 方法

定義

當實作時,提供寫入本文內容時的擴充點。When implemented, provides an extensibility point when the body contents are written.

protected:
 abstract void OnWriteBodyContents(System::Xml::XmlDictionaryWriter ^ writer);
protected abstract void OnWriteBodyContents (System.Xml.XmlDictionaryWriter writer);
abstract member OnWriteBodyContents : System.Xml.XmlDictionaryWriter -> unit
Protected MustOverride Sub OnWriteBodyContents (writer As XmlDictionaryWriter)

參數

writer
XmlDictionaryWriter

用於寫出訊息本文的 XmlDictionaryWriterThe XmlDictionaryWriter used to write out the message body.

範例

下列範例說明 OnWriteBodyContents(XmlDictionaryWriter) 方法的覆寫。The following example illustrates an override of the OnWriteBodyContents(XmlDictionaryWriter) method.

protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
   writer.WriteStartElement(textTag);

   foreach (string str in bodySegment)
   {
       writer.WriteString(str);
   }

    writer.WriteEndElement();
}
Protected Overrides Sub OnWriteBodyContents(ByVal writer As XmlDictionaryWriter)
   writer.WriteStartElement(textTag)

    For Each str As String In bodySegment
        writer.WriteString(str)
    Next str

    writer.WriteEndElement()
End Sub

備註

這個方法必須由衍生自 BodyWriter 的類別實作。This method must be implemented by classes derived from BodyWriter. 這是寫入本文的重要方法。This is the key method that writes the body. 如果 BodyWriter 已緩衝處理,則這個方法只會呼叫一次。If the BodyWriter is buffered then this method is called only once.

適用於