BodyWriter.OnWriteBodyContents(XmlDictionaryWriter) 方法

定义

实现时,提供写入正文内容时的可扩展点。

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

用于写出消息正文的 XmlDictionaryWriter

示例

下面的示例演示 OnWriteBodyContents(XmlDictionaryWriter) 方法的重写。

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 的类实现。 这是写入正文的关键方法。 如果缓冲 BodyWriter,则仅调用一次此方法。

适用于