microsoft-visualbasic-runtime/ComponentModel/File/XmlDataModel.vb

98 lines
3.1 KiB
VB.net
Raw Normal View History

2018-10-27 11:43:28 +08:00
#Region "Microsoft.VisualBasic::2777494b64a6dee643a2bb43c96fd553, Microsoft.VisualBasic.Core\ComponentModel\File\XmlDataModel.vb"
2018-08-02 20:14:48 +08:00
' Author:
'
' asuka (amethyst.asuka@gcmodeller.org)
' xie (genetics@smrucc.org)
' xieguigang (xie.guigang@live.com)
'
' Copyright (c) 2018 GPL3 Licensed
'
'
' GNU GENERAL PUBLIC LICENSE (GPL3)
'
'
' This program is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by
' the Free Software Foundation, either version 3 of the License, or
' (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program. If not, see <http://www.gnu.org/licenses/>.
2018-08-02 20:14:48 +08:00
' /********************************************************************************/
2018-08-02 20:14:48 +08:00
' Summaries:
2018-08-02 20:14:48 +08:00
' Class XmlDataModel
'
' Properties: TypeComment
'
' Function: GetTypeReferenceComment
'
'
' /********************************************************************************/
2018-08-02 20:14:48 +08:00
#End Region
Imports System.IO
2018-08-02 20:14:48 +08:00
Imports System.Runtime.CompilerServices
Imports System.Runtime.Serialization
Imports System.Web.Script.Serialization
Imports System.Xml
Imports System.Xml.Serialization
Imports Microsoft.VisualBasic.SecurityString
2018-08-02 20:14:48 +08:00
Namespace ComponentModel
2018-10-26 21:51:15 +08:00
''' <summary>
''' 这个基类型对象主要是用来生成类型全称注释方便编写XML文件加载代码功能的
''' </summary>
2018-08-02 20:14:48 +08:00
Public MustInherit Class XmlDataModel
''' <summary>
''' ReadOnly, Data model type tracking use Xml Comment.
''' </summary>
''' <returns></returns>
'''
<DataMember>
<IgnoreDataMember>
<ScriptIgnore>
<SoapIgnore>
<XmlAnyElement>
Public Property TypeComment As XmlComment
<MethodImpl(MethodImplOptions.AggressiveInlining)>
Get
Return GetTypeReferenceComment()
End Get
Set(value As XmlComment)
' Do Nothing
' 2018-6-5 this xml comment node cause bug when using xml deserialization
End Set
End Property
Private Function GetTypeReferenceComment() As XmlComment
Dim modelType As Type = Me.GetType
Dim fullName$ = modelType.FullName
Dim assembly$ = modelType.Assembly.FullName
Dim update As Date = File.GetLastWriteTime(modelType.Assembly.Location)
Dim md5$ = modelType.Assembly.Location.GetFileHashString
2018-08-02 20:14:48 +08:00
Dim trace$ = vbCrLf &
" model: " & fullName & vbCrLf &
" assembly: " & assembly & vbCrLf &
" md5: " & md5 & vbCrLf &
" timestamp: " & update.ToLongTimeString & vbCrLf &
2018-08-02 20:14:48 +08:00
" "
Return New XmlDocument().CreateComment(trace)
End Function
End Class
End Namespace