本文整理匯總了VB.NET中System.Xml.Serialization.XmlAttributeOverrides.Item屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET XmlAttributeOverrides.Item屬性的具體用法?VB.NET XmlAttributeOverrides.Item怎麽用?VB.NET XmlAttributeOverrides.Item使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Xml.Serialization.XmlAttributeOverrides
的用法示例。
在下文中一共展示了XmlAttributeOverrides.Item屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: CreateOverrider
' This is the class that will be serialized.
Public Class Group
Public GroupName As String
<XmlAttribute()> Public GroupCode As Integer
End Class
Public Class Sample
Public Function CreateOverrider() As XmlSerializer
' Create an XmlSerializer with overriding attributes.
Dim attrs As New XmlAttributes()
Dim xOver As New XmlAttributeOverrides()
Dim xRoot As New XmlRootAttribute()
' Set a new Namespace and ElementName for the root element.
xRoot.Namespace = "http://www.cpandl.com"
xRoot.ElementName = "NewGroup"
attrs.XmlRoot = xRoot
xOver.Add(GetType(Group), attrs)
' Get the XmlAttributes object, based on the type.
Dim tempAttrs As XmlAttributes
tempAttrs = xOver(GetType(Group))
' Print the Namespace and ElementName of the root.
Console.WriteLine(tempAttrs.XmlRoot.Namespace)
Console.WriteLine(tempAttrs.XmlRoot.ElementName)
Dim xSer As New XmlSerializer(GetType(Group), xOver)
Return xSer
End Function
End Class
示例2: CreateOverrider
' This is the class that will be serialized.
Public Class Group
Public GroupName As String
<XmlAttribute()> Public GroupCode As Integer
End Class
Public Class Sample
Public Function CreateOverrider() As XmlSerializer
' Create an XmlSerializer with overriding attributes.
Dim xOver As New XmlAttributeOverrides()
' Create an XmlAttributeAttribute object and set the
' AttributeName property.
Dim xAtt As New XmlAttributeAttribute()
xAtt.AttributeName = "Code"
' Create a new XmlAttributes object and set the
' XmlAttributeAttribute object to the XmlAttribute property.
Dim attrs As New XmlAttributes()
attrs.XmlAttribute = xAtt
' Add the XmlAttributes to the XmlAttributeOverrides object. The
' name of the overridden attribute must be specified.
xOver.Add(GetType(Group), "GroupCode", attrs)
' Get the XmlAttributes object for the type and member.
Dim tempAttrs As XmlAttributes
tempAttrs = xOver(GetType(Group), "GroupCode")
Console.WriteLine(tempAttrs.XmlAttribute.AttributeName)
' Create the XmlSerializer instance and return it.
Dim xSer As New XmlSerializer(GetType(Group), xOver)
Return xSer
End Function
End Class