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.

适用于