2019-06-04 20:43:55 +08:00
|
|
|
|
#Region "Microsoft.VisualBasic::fd14a1e412dbfbcce36ab762392d0470, Microsoft.VisualBasic.Core\ComponentModel\File\XmlDataModel.vb"
|
2018-08-02 20:14:48 +08:00
|
|
|
|
|
2019-05-06 18:27:46 +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-05-06 18:27:46 +08:00
|
|
|
|
' /********************************************************************************/
|
2018-08-02 20:14:48 +08:00
|
|
|
|
|
2019-05-06 18:27:46 +08:00
|
|
|
|
' Summaries:
|
2018-08-02 20:14:48 +08:00
|
|
|
|
|
2019-05-06 18:27:46 +08:00
|
|
|
|
' Class XmlDataModel
|
|
|
|
|
|
'
|
|
|
|
|
|
' Properties: TypeComment
|
|
|
|
|
|
'
|
|
|
|
|
|
' Function: (+2 Overloads) GetTypeReferenceComment
|
|
|
|
|
|
'
|
|
|
|
|
|
' Sub: SaveTypeComment
|
|
|
|
|
|
' Interface IXmlType
|
|
|
|
|
|
'
|
|
|
|
|
|
' Properties: TypeComment
|
|
|
|
|
|
'
|
|
|
|
|
|
'
|
|
|
|
|
|
'
|
|
|
|
|
|
'
|
|
|
|
|
|
' /********************************************************************************/
|
2018-08-02 20:14:48 +08:00
|
|
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
2018-11-17 18:49:18 +08:00
|
|
|
|
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
|
2018-11-17 18:49:18 +08:00
|
|
|
|
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>
|
2019-04-29 18:21:51 +08:00
|
|
|
|
Public MustInherit Class XmlDataModel : Implements IXmlType
|
|
|
|
|
|
|
|
|
|
|
|
''' <summary>
|
|
|
|
|
|
''' 只适合最外层面的容器类型的对象来实现
|
|
|
|
|
|
''' </summary>
|
|
|
|
|
|
Public Interface IXmlType
|
|
|
|
|
|
Property TypeComment As XmlComment
|
|
|
|
|
|
End Interface
|
2018-08-02 20:14:48 +08:00
|
|
|
|
|
|
|
|
|
|
''' <summary>
|
|
|
|
|
|
''' ReadOnly, Data model type tracking use Xml Comment.
|
|
|
|
|
|
''' </summary>
|
|
|
|
|
|
''' <returns></returns>
|
2019-05-31 19:14:18 +08:00
|
|
|
|
''' <remarks>
|
|
|
|
|
|
''' JSON存储的时候,这个属性会被自动忽略掉
|
|
|
|
|
|
''' </remarks>
|
2018-08-02 20:14:48 +08:00
|
|
|
|
<DataMember>
|
|
|
|
|
|
<IgnoreDataMember>
|
|
|
|
|
|
<ScriptIgnore>
|
|
|
|
|
|
<SoapIgnore>
|
|
|
|
|
|
<XmlAnyElement>
|
2019-04-29 18:21:51 +08:00
|
|
|
|
Public Property TypeComment As XmlComment Implements IXmlType.TypeComment
|
2018-08-02 20:14:48 +08:00
|
|
|
|
<MethodImpl(MethodImplOptions.AggressiveInlining)>
|
|
|
|
|
|
Get
|
|
|
|
|
|
Return GetTypeReferenceComment()
|
|
|
|
|
|
End Get
|
|
|
|
|
|
Set(value As XmlComment)
|
|
|
|
|
|
' Do Nothing
|
2019-05-31 19:14:18 +08:00
|
|
|
|
' 2018-6-5 this xml comment node cause bug
|
|
|
|
|
|
' when using xml deserialization
|
2018-08-02 20:14:48 +08:00
|
|
|
|
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
|
|
|
|
|
|
|
2019-04-29 18:21:51 +08:00
|
|
|
|
Public Shared Sub SaveTypeComment(model As IXmlType)
|
|
|
|
|
|
model.TypeComment = New XmlDocument().CreateComment(GetTypeReferenceComment(model.GetType))
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
2019-04-17 21:03:36 +08:00
|
|
|
|
''' <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
|
2018-11-17 18:49:18 +08:00
|
|
|
|
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
|