本文整理匯總了VB.NET中System.ServiceModel.Channels.BodyWriter類的典型用法代碼示例。如果您正苦於以下問題:VB.NET BodyWriter類的具體用法?VB.NET BodyWriter怎麽用?VB.NET BodyWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了BodyWriter類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: New
' 導入命名空間
Imports System.Text
Imports System.ServiceModel
Imports System.ServiceModel.Channels
Imports System.Xml
Namespace UEBodyWriter
Friend Class MyBodyWriter
Inherits BodyWriter
Private Const textTag As String = "text"
Private bodySegment() As String
Public Sub New(ByVal strData() As String)
MyBase.New(True)
Dim length = strData.Length
Me.bodySegment = New String(length - 1){}
For i = 0 To length - 1
Me.bodySegment(i) = strData(i)
Next i
End Sub
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
End Class
Module Module1
Sub Main(ByVal args() As String)
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()
End Sub
End Module
End Namespace