1 | #Region "Microsoft.VisualBasic::34156b971341d9f178c56966b3b3ca89, Microsoft.VisualBasic.Core\ComponentModel\File\XmlDataModel.vb" |
2 | |
3 | ' Author: |
4 | ' |
5 | ' asuka (amethyst.asuka@gcmodeller.org) |
6 | ' xie (genetics@smrucc.org) |
7 | ' xieguigang (xie.guigang@live.com) |
8 | ' |
9 | ' Copyright (c) 2018 GPL3 Licensed |
10 | ' |
11 | ' |
12 | ' GNU GENERAL PUBLIC LICENSE (GPL3) |
13 | ' |
14 | ' |
15 | ' This program is free software: you can redistribute it and/or modify |
16 | ' it under the terms of the GNU General Public License as published by |
17 | ' the Free Software Foundation, either version 3 of the License, or |
18 | ' (at your option) any later version. |
19 | ' |
20 | ' This program is distributed in the hope that it will be useful, |
21 | ' but WITHOUT ANY WARRANTY; without even the implied warranty of |
22 | ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23 | ' GNU General Public License for more details. |
24 | ' |
25 | ' You should have received a copy of the GNU General Public License |
26 | ' along with this program. If not, see <http://www.gnu.org/licenses/>. |
27 | |
28 | |
29 | |
30 | ' /********************************************************************************/ |
31 | |
32 | ' Summaries: |
33 | |
34 | ' Class XmlDataModel |
35 | ' |
36 | ' Properties: TypeComment |
37 | ' |
38 | ' Function: GetTypeReferenceComment |
39 | ' |
40 | ' |
41 | ' /********************************************************************************/ |
42 | |
43 | #End Region |
44 | |
45 | Imports System.IO |
46 | Imports System.Runtime.CompilerServices |
47 | Imports System.Runtime.Serialization |
48 | Imports System.Web.Script.Serialization |
49 | Imports System.Xml |
50 | Imports System.Xml.Serialization |
51 | Imports Microsoft.VisualBasic.SecurityString |
52 | |
53 | Namespace ComponentModel |
54 | |
55 | ''' <summary> |
56 | ''' 这个基类型对象主要是用来生成类型全称注释方便编写XML文件加载代码功能的 |
57 | ''' </summary> |
58 | Public MustInherit Class XmlDataModel |
59 | |
60 | ''' <summary> |
61 | ''' ReadOnly, Data model type tracking use Xml Comment. |
62 | ''' </summary> |
63 | ''' <returns></returns> |
64 | ''' <DataMember> |
65 | <IgnoreDataMember> |
66 | <ScriptIgnore> |
67 | <SoapIgnore> |
68 | <XmlAnyElement> |
69 | Public Property TypeComment As XmlComment |
70 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
71 | Get |
72 | Return GetTypeReferenceComment() |
73 | End Get |
74 | Set(value As XmlComment) |
75 | ' Do Nothing |
76 | ' 2018-6-5 this xml comment node cause bug when using xml deserialization |
77 | End Set |
78 | End Property |
79 | |
80 | Private Function GetTypeReferenceComment() As XmlComment |
81 | Dim modelType As Type = Me.GetType |
82 | Dim fullName$ = modelType.FullName |
83 | Dim assembly$ = modelType.Assembly.FullName |
84 | Dim update As Date = File.GetLastWriteTime(modelType.Assembly.Location) |
85 | Dim md5$ = modelType.Assembly.Location.GetFileHashString |
86 | Dim trace$ = vbCrLf & |
87 | " model: " & fullName & vbCrLf & |
88 | " assembly: " & assembly & vbCrLf & |
89 | " md5: " & md5 & vbCrLf & |
90 | " timestamp: " & update.ToLongDateString & vbCrLf & |
91 | " " |
92 | |
93 | Return New XmlDocument().CreateComment(trace) |
94 | End Function |
95 | End Class |
96 | End Namespace |