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) 會提供最佳的擴充點。