BodyWriter.OnWriteBodyContents(XmlDictionaryWriter) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
实现时,提供写入正文内容时的可扩展点。
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,则仅调用一次此方法。