本文整理匯總了VB.NET中System.Runtime.Serialization.DataContractSerializer.IsStartObject方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET DataContractSerializer.IsStartObject方法的具體用法?VB.NET DataContractSerializer.IsStartObject怎麽用?VB.NET DataContractSerializer.IsStartObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Runtime.Serialization.DataContractSerializer
的用法示例。
在下文中一共展示了DataContractSerializer.IsStartObject方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: ReadObjectData
Public Shared Sub ReadObjectData(ByVal path As String)
' Create the reader.
Dim fs As New FileStream(path, FileMode.Open)
Dim reader As XmlDictionaryReader = _
XmlDictionaryReader.CreateTextReader(fs, New XmlDictionaryReaderQuotas())
' Create the DataContractSerializer specifying the type,
' root and namespace to use. The root value corresponds
' to the DataContract.Name value, and the namespace value
' corresponds to the DataContract.Namespace value.
Dim ser As New DataContractSerializer(GetType(Person), _
"Customer", "http://www.contoso.com")
' Test if the serializer is on the start of the
' object data. If so, read the data and write it
' to the console.
While reader.Read()
If ser.IsStartObject(reader) Then
Console.WriteLine("Found the element")
Dim p As Person = CType(ser.ReadObject(reader), Person)
Console.WriteLine("{0} {1} id:{2}", p.FirstName, p.LastName, p.ID)
End If
Console.WriteLine(reader.Name)
End While
fs.Flush()
fs.Close()
End Sub