<Serializable>
<XmlRoot(ElementName := "Root">
Property ID As Integer
Property Code As String
Property Name As String
Property Description As String
Property Comments As String
Property Pinyin As String
Property Aliases As New XmlDocument
Property OrderNo As Integer
'序列化时忽略此属性
<XmlIgnore>
Property ActFrom As Date
'序列化时该属性序列化为"ActFrom"节点
<XmlElement(ElementName:="ActFrom")>
Property FormatActFrom As String
Get
Return ActFrom.ToString("yyyy-MM-dd HH:mm")
End Get
Set(value As String)
ActFrom = Date.Parse(value)
End Set
End Property
<XmlIgnore>
Property ActTo As Date
<XmlElement(ElementName:="ActTo")>
Property FormatActTo As String
Get
Return ActTo.ToString("yyyy-MM-dd HH:mm")
End Get
Set(value As String)
ActTo = Date.Parse(value)
End Set
End Property
ReadOnly Property Active As Boolean
Get
Return Date.Now >= ActFrom And Date.Now <= ActTo
End Get
End Property
Public Sub New()
End SubEnd Class
VB.Net XML序列化中格式化日期
最新推荐文章于 2025-05-04 16:31:46 发布