1 | #Region "Microsoft.VisualBasic::7b499fce2c4087ff8463902e9d0bdfcb, Microsoft.VisualBasic.Core\Language\Value\var.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 Value |
35 | ' |
36 | ' Properties: IsNumeric, IsString, Name, Trace, Type |
37 | ' |
38 | ' Function: ToString |
39 | ' |
40 | ' |
41 | ' /********************************************************************************/ |
42 | |
43 | #End Region |
44 | |
45 | Imports System.Reflection |
46 | Imports Microsoft.VisualBasic.ComponentModel.Collection.Generic |
47 | Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel |
48 | Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel.Repository |
49 | |
50 | Namespace Language |
51 | |
52 | ''' <summary> |
53 | ''' Variable model in VisualBasic |
54 | ''' </summary> |
55 | Public Class Value : Inherits Value(Of Object) |
56 | Implements INamedValue |
57 | |
58 | Public Property Name As String Implements IKeyedEntity(Of String).Key |
59 | Public Property Type As Type |
60 | ''' <summary> |
61 | ''' 这个变量所在的函数的位置记录 |
62 | ''' </summary> |
63 | ''' <returns></returns> |
64 | Public Property Trace As NamedValue(Of MethodBase) |
65 | |
66 | ''' <summary> |
67 | ''' Is a numeric type? |
68 | ''' </summary> |
69 | ''' <returns></returns> |
70 | Public ReadOnly Property IsNumeric As Boolean |
71 | Get |
72 | Dim tcode As TypeCode = Type.GetTypeCode(Type) |
73 | |
74 | If tcode = TypeCode.Byte OrElse |
75 | tcode = TypeCode.Decimal OrElse |
76 | tcode = TypeCode.Double OrElse |
77 | tcode = TypeCode.Int16 OrElse |
78 | tcode = TypeCode.Int32 OrElse |
79 | tcode = TypeCode.Int64 OrElse |
80 | tcode = TypeCode.Single OrElse |
81 | tcode = TypeCode.UInt16 OrElse |
82 | tcode = TypeCode.UInt32 OrElse |
83 | tcode = TypeCode.UInt64 Then |
84 | |
85 | Return True |
86 | Else |
87 | Return False |
88 | End If |
89 | End Get |
90 | End Property |
91 | |
92 | Public ReadOnly Property IsString As Boolean |
93 | Get |
94 | Return Type.Equals(GetType(String)) |
95 | End Get |
96 | End Property |
97 | |
98 | Public Overrides Function ToString() As String |
99 | If value Is Nothing Then |
100 | Return Nothing |
101 | End If |
102 | Return value.ToString |
103 | End Function |
104 | End Class |
105 | End Namespace |