| 1 | #Region "Microsoft.VisualBasic::68b027c2426ee954592b66c111ef89b7, Microsoft.VisualBasic.Core\ComponentModel\ValuePair\TagData\TagData.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 TagData |
| 35 | ' |
| 36 | ' Properties: Key, Tag, TagStr |
| 37 | ' |
| 38 | ' Class IntegerTagged |
| 39 | ' |
| 40 | ' |
| 41 | ' |
| 42 | ' Class DoubleTagged |
| 43 | ' |
| 44 | ' |
| 45 | ' |
| 46 | ' Class LongTagged |
| 47 | ' |
| 48 | ' |
| 49 | ' |
| 50 | ' Class DateTagged |
| 51 | ' |
| 52 | ' |
| 53 | ' |
| 54 | ' Class VectorTagged |
| 55 | ' |
| 56 | ' |
| 57 | ' |
| 58 | ' |
| 59 | ' /********************************************************************************/ |
| 60 | |
| 61 | #End Region |
| 62 | |
| 63 | Imports Microsoft.VisualBasic.ComponentModel.Collection.Generic |
| 64 | Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel.Repository |
| 65 | Imports Microsoft.VisualBasic.Language |
| 66 | Imports Microsoft.VisualBasic.Serialization.JSON |
| 67 | |
| 68 | Namespace ComponentModel.TagData |
| 69 | |
| 70 | ''' <summary> |
| 71 | ''' Target value have a specific tag key. |
| 72 | ''' </summary> |
| 73 | ''' <typeparam name="T">The type of the tag key</typeparam> |
| 74 | ''' <typeparam name="V">The type of the value data</typeparam> |
| 75 | Public Class TagData(Of T, V) : Inherits Value(Of V) |
| 76 | Implements INamedValue |
| 77 | |
| 78 | ''' <summary> |
| 79 | ''' ``<see cref="Tag"/> -> <see cref="GetJson"/>`` |
| 80 | ''' </summary> |
| 81 | ''' <returns></returns> |
| 82 | Private Property Key As String Implements IKeyedEntity(Of String).Key |
| 83 | Get |
| 84 | Return Tag.GetJson |
| 85 | End Get |
| 86 | Set(value As String) |
| 87 | Tag = value.LoadJSON(Of T) |
| 88 | End Set |
| 89 | End Property |
| 90 | |
| 91 | ''' <summary> |
| 92 | ''' Target value have this specific tag data. |
| 93 | ''' </summary> |
| 94 | ''' <returns></returns> |
| 95 | Public Property Tag As T |
| 96 | |
| 97 | ''' <summary> |
| 98 | ''' 默认都有一个字符串类型的标签用于保存其他的数据,但是主要还是使用``<see cref="Tag"/>``属性来进行标记 |
| 99 | ''' </summary> |
| 100 | ''' <returns></returns> |
| 101 | Public Property TagStr As String |
| 102 | |
| 103 | Public Overloads Shared Narrowing Operator CType(t As TagData(Of T, V)) As KeyValuePair(Of T, V) |
| 104 | Return New KeyValuePair(Of T, V)(t.Tag, t.Value) |
| 105 | End Operator |
| 106 | |
| 107 | ''' <summary> |
| 108 | ''' 将这个标签数据转换为``元组``类型 |
| 109 | ''' </summary> |
| 110 | ''' <param name="r"></param> |
| 111 | ''' <returns></returns> |
| 112 | Public Overloads Shared Narrowing Operator CType(r As TagData(Of T, V)) As Tuple(Of T, V) |
| 113 | Return New Tuple(Of T, V)(r.Tag, r.Value) |
| 114 | End Operator |
| 115 | End Class |
| 116 | |
| 117 | ''' <summary> |
| 118 | ''' 使用一个整形数作为目标对象值的标签信息 |
| 119 | ''' </summary> |
| 120 | ''' <typeparam name="T"></typeparam> |
| 121 | Public Class IntegerTagged(Of T) : Inherits TagData(Of Integer, T) |
| 122 | |
| 123 | End Class |
| 124 | |
| 125 | ''' <summary> |
| 126 | ''' 使用一个实数作为目标对象值的标签信息 |
| 127 | ''' </summary> |
| 128 | ''' <typeparam name="T"></typeparam> |
| 129 | Public Class DoubleTagged(Of T) : Inherits TagData(Of Double, T) |
| 130 | |
| 131 | End Class |
| 132 | |
| 133 | ''' <summary> |
| 134 | ''' 使用一个长整形数作为目标对象值的标签信息 |
| 135 | ''' </summary> |
| 136 | ''' <typeparam name="T"></typeparam> |
| 137 | Public Class LongTagged(Of T) : Inherits TagData(Of Long, T) |
| 138 | |
| 139 | End Class |
| 140 | |
| 141 | Public Class DateTagged(Of T) : Inherits TagData(Of Date, T) |
| 142 | |
| 143 | End Class |
| 144 | |
| 145 | Public Class VectorTagged(Of T) : Inherits TagData(Of Double(), T) |
| 146 | |
| 147 | End Class |
| 148 | End Namespace |