本文整理汇总了VB.NET中System.Xml.Serialization.SoapAttributeOverrides.Item属性的典型用法代码示例。如果您正苦于以下问题:VB.NET SoapAttributeOverrides.Item属性的具体用法?VB.NET SoapAttributeOverrides.Item怎么用?VB.NET SoapAttributeOverrides.Item使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Xml.Serialization.SoapAttributeOverrides
的用法示例。
在下文中一共展示了SoapAttributeOverrides.Item属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Group
' 导入命名空间
Imports System.IO
Imports System.Xml
Imports System.Xml.Serialization
' The name of this type will be overridden using
' the SoapTypeAttribute.
Public Class Group
Public GroupName As String
End Class
Public Class Run
Shared Sub Main()
Dim test As Run = new Run()
test.SerializeOverride("GetSoapAttributesVB2.xml")
End Sub
Public Sub SerializeOverride(filename As string )
' Create an instance of the XmlSerializer class
' that overrides the serialization.
Dim overrideSerializer As XmlSerializer = _
CreateOverrideSerializer()
' Writing the file requires a TextWriter.
Dim writer As TextWriter = new StreamWriter(filename)
' Create an instance of the class that will be serialized.
Dim myGroup As Group = new Group()
' Set the object properties.
myGroup.GroupName = ".NET"
' Serialize the class, and close the TextWriter.
overrideSerializer.Serialize(writer, myGroup)
writer.Close()
End Sub
Private Function CreateOverrideSerializer() As XmlSerializer
Dim mySoapAttributeOverrides As SoapAttributeOverrides = _
New SoapAttributeOverrides()
Dim mySoapAtts As SoapAttributes = new SoapAttributes()
Dim mySoapType As SoapTypeAttribute = _
new SoapTypeAttribute()
mySoapType.TypeName = "Team"
mySoapAtts.SoapType = mySoapType
' Add the SoapAttributes to the
' mySoapAttributeOverridesrides object.
mySoapAttributeOverrides.Add(GetType(Group), mySoapAtts)
' Get the SoapAttributes with the Item property.
Dim thisSoapAtts As SoapAttributes = _
mySoapAttributeOverrides(GetType(Group))
Console.WriteLine("New serialized type name: " & _
thisSoapAtts.SoapType.TypeName)
' Create an XmlTypeMapping that is used to create an instance
' of the XmlSerializer. Then return the XmlSerializer object.
Dim myMapping As XmlTypeMapping = _
(New SoapReflectionImporter(mySoapAttributeOverrides)). _
ImportTypeMapping(GetType(Group))
Dim ser As XmlSerializer = new XmlSerializer(myMapping)
return ser
End Function
End Class
示例2: Group
' 导入命名空间
Imports System.IO
Imports System.Xml
Imports System.Xml.Serialization
Public Class Group
' Override the serialization of this member.
Public GroupName As String
End Class
Public Class Run
Shared Sub Main()
Dim test As Run = new Run()
test.SerializeOverride("GetSoapAttributesVB.xml")
End Sub
Public Sub SerializeOverride(filename As string )
' Create an instance of the XmlSerializer class
' that overrides the serialization.
Dim overrideSerializer As XmlSerializer = _
CreateOverrideSerializer()
' Writing the file requires a TextWriter.
Dim writer As TextWriter = new StreamWriter(filename)
' Create an instance of the class that will be serialized.
Dim myGroup As Group = new Group()
' Set the object properties.
myGroup.GroupName = ".NET"
' Serialize the class, and close the TextWriter.
overrideSerializer.Serialize(writer, myGroup)
writer.Close()
End Sub
Private Function CreateOverrideSerializer() As XmlSerializer
Dim mySoapAttributeOverrides As SoapAttributeOverrides = _
New SoapAttributeOverrides()
Dim mySoapAtts As SoapAttributes = new SoapAttributes()
Dim mySoapElement As SoapElementAttribute = _
new SoapElementAttribute()
mySoapElement.ElementName = "TeamName"
mySoapAtts.SoapElement = mySoapElement
' Add the SoapAttributes to the
' mySoapAttributeOverridesrides object.
mySoapAttributeOverrides.Add(GetType(Group), "GroupName", _
mySoapAtts)
' Get the SoapAttributes with the Item property.
Dim thisSoapAtts As SoapAttributes = _
mySoapAttributeOverrides(GetType(Group), "GroupName")
Console.WriteLine("New serialized element name: " & _
thisSoapAtts.SoapElement.ElementName)
' Create an XmlTypeMapping that is used to create an instance
' of the XmlSerializer. Then return the XmlSerializer object.
Dim myMapping As XmlTypeMapping = _
(New SoapReflectionImporter(mySoapAttributeOverrides)). _
ImportTypeMapping(GetType(Group))
Dim ser As XmlSerializer = new XmlSerializer(myMapping)
return ser
End Function
End Class