| 1 | #Region "Microsoft.VisualBasic::776b8416ea8cd286200447e3e5c93cf2, Microsoft.VisualBasic.Core\Scripting\MetaData\EntryPointMetaData.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 FunctionReturns |
| 35 | ' |
| 36 | ' Properties: Description, TypeRef |
| 37 | ' |
| 38 | ' Constructor: (+1 Overloads) Sub New |
| 39 | ' Function: GetDescription, ToString |
| 40 | ' |
| 41 | ' Class OverloadsSignatureHandle |
| 42 | ' |
| 43 | ' Properties: FullName, TypeIDBrief |
| 44 | ' |
| 45 | ' Constructor: (+1 Overloads) Sub New |
| 46 | ' Function: ToString |
| 47 | ' |
| 48 | ' Class ImportsConstant |
| 49 | ' |
| 50 | ' Properties: Name, TypeInfo |
| 51 | ' |
| 52 | ' Constructor: (+1 Overloads) Sub New |
| 53 | ' Function: ToString |
| 54 | ' |
| 55 | ' |
| 56 | ' /********************************************************************************/ |
| 57 | |
| 58 | #End Region |
| 59 | |
| 60 | Imports System.Reflection |
| 61 | |
| 62 | Namespace Scripting.MetaData |
| 63 | |
| 64 | <AttributeUsage(AttributeTargets.ReturnValue, AllowMultiple:=False, Inherited:=True)> |
| 65 | Public Class FunctionReturns : Inherits Attribute |
| 66 | |
| 67 | Public ReadOnly Property Description As String |
| 68 | |
| 69 | Sub New(Description As String) |
| 70 | Me.Description = Description |
| 71 | End Sub |
| 72 | |
| 73 | Public Overrides Function ToString() As String |
| 74 | Return Description |
| 75 | End Function |
| 76 | |
| 77 | Public Shared ReadOnly Property TypeRef As Type = GetType(FunctionReturns) |
| 78 | |
| 79 | ''' <summary> |
| 80 | ''' Gets the description of the function returns value |
| 81 | ''' </summary> |
| 82 | ''' <param name="method"></param> |
| 83 | ''' <returns></returns> |
| 84 | Public Shared Function GetDescription(method As MethodInfo) As String |
| 85 | Dim attrs As Object() = method.ReturnParameter.GetCustomAttributes(attributeType:=FunctionReturns.TypeRef, inherit:=True) |
| 86 | If attrs.IsNullOrEmpty Then |
| 87 | Return "" |
| 88 | End If |
| 89 | |
| 90 | Dim value = DirectCast(attrs(Scan0), FunctionReturns).Description |
| 91 | Return value |
| 92 | End Function |
| 93 | End Class |
| 94 | |
| 95 | ''' <summary> |
| 96 | ''' 用于解决函数重载的函数数字签名的属性 |
| 97 | ''' </summary> |
| 98 | ''' <remarks></remarks> |
| 99 | <AttributeUsage(AttributeTargets.Class, AllowMultiple:=True, Inherited:=True)> |
| 100 | Public Class OverloadsSignatureHandle : Inherits Attribute |
| 101 | |
| 102 | Public ReadOnly Property TypeIDBrief As String |
| 103 | Public ReadOnly Property FullName As Type |
| 104 | |
| 105 | ''' <summary> |
| 106 | ''' |
| 107 | ''' </summary> |
| 108 | ''' <param name="TypeIdBrief">Brief name for the target signature type <paramref name="FullName"></paramref></param> |
| 109 | ''' <param name="FullName">Target signature type for function overloads.</param> |
| 110 | ''' <remarks></remarks> |
| 111 | Sub New(TypeIdBrief As String, FullName As Type) |
| 112 | _TypeIDBrief = TypeIdBrief.ToLower |
| 113 | _FullName = FullName |
| 114 | End Sub |
| 115 | |
| 116 | Public Overrides Function ToString() As String |
| 117 | Return String.Format("({0}) {1}", _TypeIDBrief, _FullName.FullName) |
| 118 | End Function |
| 119 | End Class |
| 120 | |
| 121 | <AttributeUsage(AttributeTargets.Field, AllowMultiple:=False, Inherited:=True)> |
| 122 | Public Class ImportsConstant : Inherits Attribute |
| 123 | |
| 124 | Public ReadOnly Property Name As String |
| 125 | |
| 126 | Sub New(<Parameter("imports.constant", "")> Optional Name As String = "") |
| 127 | _Name = Name |
| 128 | End Sub |
| 129 | |
| 130 | Public Overrides Function ToString() As String |
| 131 | Return Name |
| 132 | End Function |
| 133 | |
| 134 | Public Shared ReadOnly Property TypeInfo As Type = GetType(ImportsConstant) |
| 135 | |
| 136 | End Class |
| 137 | End Namespace |