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