| 1 | #Region "Microsoft.VisualBasic::ba36342729a2e4f0c9bedbc46e625971, Microsoft.VisualBasic.Core\ComponentModel\Settings\DataModels\ProfileItem.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 | ' Enum ValueTypes |
| 35 | ' |
| 36 | ' [Double], [Integer], Directory, File, Text |
| 37 | ' |
| 38 | ' |
| 39 | ' |
| 40 | ' |
| 41 | ' |
| 42 | ' Class ProfileItem |
| 43 | ' |
| 44 | ' Properties: Description, Name, Type |
| 45 | ' |
| 46 | ' Constructor: (+2 Overloads) Sub New |
| 47 | ' Function: ToString |
| 48 | ' |
| 49 | ' Class ProfileNodeItem |
| 50 | ' |
| 51 | ' |
| 52 | ' |
| 53 | ' |
| 54 | ' /********************************************************************************/ |
| 55 | |
| 56 | #End Region |
| 57 | |
| 58 | Imports System.Xml.Serialization |
| 59 | Imports Microsoft.VisualBasic.ComponentModel.Collection.Generic |
| 60 | |
| 61 | Namespace ComponentModel.Settings |
| 62 | |
| 63 | ''' <summary> |
| 64 | ''' 这个并不是指宿主属性的数据类型,而是指代这一数据类型所代表的具体的实际对象 |
| 65 | ''' </summary> |
| 66 | Public Enum ValueTypes |
| 67 | ''' <summary> |
| 68 | ''' 这个字符串的值是一个文件夹 |
| 69 | ''' </summary> |
| 70 | Directory |
| 71 | ''' <summary> |
| 72 | ''' 这个字符串的值是一个文件的路径 |
| 73 | ''' </summary> |
| 74 | File |
| 75 | ''' <summary> |
| 76 | ''' 普通的文本字符串 |
| 77 | ''' </summary> |
| 78 | Text |
| 79 | ''' <summary> |
| 80 | ''' 带有小数的数值 |
| 81 | ''' </summary> |
| 82 | [Double] |
| 83 | ''' <summary> |
| 84 | ''' 整数 |
| 85 | ''' </summary> |
| 86 | [Integer] |
| 87 | End Enum |
| 88 | |
| 89 | ''' <summary> |
| 90 | ''' The simple configuration mapping node in the current profile data, the data type of this node |
| 91 | ''' object should be just the simplest data type such as String, Integer, Long, Double, Boolean. |
| 92 | ''' (当前的配置节点为一个简单节点,即目标属性的属性值类型的字符串,数字或者逻辑值等最基本的数据类型) |
| 93 | ''' </summary> |
| 94 | ''' <remarks></remarks> |
| 95 | <AttributeUsage(AttributeTargets.Property, AllowMultiple:=False, Inherited:=True)> |
| 96 | Public Class ProfileItem : Inherits Attribute |
| 97 | Implements IKeyValuePairObject(Of String, String) |
| 98 | Implements INamedValue |
| 99 | |
| 100 | <XmlAttribute> Public Overridable Property Name As String Implements IKeyValuePairObject(Of String, String).Key, INamedValue.Key |
| 101 | <XmlAttribute> Public Overridable Property Description As String Implements IKeyValuePairObject(Of String, String).Value |
| 102 | |
| 103 | ''' <summary> |
| 104 | ''' 默认的数据类型是字符串类型 |
| 105 | ''' </summary> |
| 106 | ''' <returns></returns> |
| 107 | Public Overridable Property Type As ValueTypes = ValueTypes.Text |
| 108 | |
| 109 | Sub New() |
| 110 | End Sub |
| 111 | |
| 112 | ''' <summary> |
| 113 | ''' Initialize a node in the settings xml document. |
| 114 | ''' </summary> |
| 115 | ''' <param name="NodeName">The name of the node in the document xml file</param> |
| 116 | ''' <param name="NodeDescription">The brief introduction information about this profile node.</param> |
| 117 | Sub New(NodeName As String, Optional NodeDescription As String = "") |
| 118 | Name = NodeName |
| 119 | Description = NodeDescription |
| 120 | End Sub |
| 121 | |
| 122 | Public Overrides Function ToString() As String |
| 123 | If Not String.IsNullOrEmpty(Description) Then |
| 124 | Return String.Format("{0}: {1}", Name, Description) |
| 125 | Else |
| 126 | Return Name |
| 127 | End If |
| 128 | End Function |
| 129 | End Class |
| 130 | |
| 131 | ''' <summary> |
| 132 | ''' 当前的配置节点为一个复杂数据类型的配置节点,即目标属性的属性类型为一个Class对象 |
| 133 | ''' </summary> |
| 134 | ''' <remarks></remarks> |
| 135 | <AttributeUsage(AttributeTargets.Property, AllowMultiple:=False, Inherited:=True)> |
| 136 | Public Class ProfileNodeItem : Inherits Attribute |
| 137 | End Class |
| 138 | End Namespace |