BodyWriter.WriteBodyContents(XmlDictionaryWriter) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
写出消息正文的内容。
public:
void WriteBodyContents(System::Xml::XmlDictionaryWriter ^ writer);
public void WriteBodyContents (System.Xml.XmlDictionaryWriter writer);
member this.WriteBodyContents : System.Xml.XmlDictionaryWriter -> unit
Public Sub WriteBodyContents (writer As XmlDictionaryWriter)
参数
- writer
- XmlDictionaryWriter
用于写出消息正文的 XmlDictionaryWriter。
例外
writer
为 null
。
示例
下面的示例演示如何调用 WriteBodyContents(XmlDictionaryWriter) 方法。
string[] strings = {"Hello", "world"};
MyBodyWriter bw = new MyBodyWriter(strings);
StringBuilder strBuilder = new StringBuilder(10);
XmlWriter writer = XmlWriter.Create(strBuilder);
XmlDictionaryWriter dictionaryWriter = XmlDictionaryWriter.CreateDictionaryWriter(writer);
bw.WriteBodyContents(dictionaryWriter);
dictionaryWriter.Flush();
Dim strings() As String = {"Hello", "world"}
Dim bw As New MyBodyWriter(strings)
Dim strBuilder As New StringBuilder(10)
Dim writer = XmlWriter.Create(strBuilder)
Dim dictionaryWriter = XmlDictionaryWriter.CreateDictionaryWriter(writer)
bw.WriteBodyContents(dictionaryWriter)
dictionaryWriter.Flush()
注解
WriteBodyContents(XmlDictionaryWriter) 的默认实现调用 OnWriteBodyContents(XmlDictionaryWriter),因此重写 OnWriteBodyContents(XmlDictionaryWriter) 提供最佳可扩展点。