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

107 lines
3.5 KiB
VB.net
Raw Normal View History

2019-03-10 18:10:46 +08:00
#Region "Microsoft.VisualBasic::286854e228755e98eb66f3c68d16232a, Microsoft.VisualBasic.Core\ComponentModel\File\XmlDataModel.vb"
2018-08-02 20:14:48 +08:00
2019-04-17 21:03:36 +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
2019-04-17 21:03:36 +08:00
' /********************************************************************************/
2018-08-02 20:14:48 +08:00
2019-04-17 21:03:36 +08:00
' Summaries:
2018-08-02 20:14:48 +08:00
2019-04-17 21:03:36 +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
2019-04-17 21:03:36 +08:00
Return New XmlDocument().CreateComment(GetTypeReferenceComment(Me.GetType))
End Function
''' <summary>
''' 生成的注释信息是默认空了四个空格的
''' </summary>
''' <param name="modelType"></param>
''' <returns></returns>
Public Shared Function GetTypeReferenceComment(modelType As Type, Optional indent% = 4) As String
2018-08-02 20:14:48 +08:00
Dim fullName$ = modelType.FullName
Dim assembly$ = modelType.Assembly.FullName
Dim update As Date = File.GetLastWriteTime(modelType.Assembly.Location)
2019-03-06 20:07:16 +08:00
Dim md5$ = modelType.Assembly.Location.GetFileMd5
2019-04-17 21:03:36 +08:00
Dim indentBlank As New String(" "c, indent)
Dim traceInfo$ = vbCrLf &
$"{indentBlank} model: " & fullName & vbCrLf &
$"{indentBlank} assembly: " & assembly & vbCrLf &
$"{indentBlank} md5: " & md5 & vbCrLf &
$"{indentBlank} timestamp: " & update.ToLongDateString & vbCrLf &
2018-08-02 20:14:48 +08:00
" "
2019-04-17 21:03:36 +08:00
Return traceInfo
2018-08-02 20:14:48 +08:00
End Function
End Class
End Namespace