本文整理汇总了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