1 | #Region "Microsoft.VisualBasic::1df9528408e5dfe40a963b7085a603f1, Microsoft.VisualBasic.Core\ApplicationServices\VBDev\XmlDoc\ProjectMember.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 ProjectMember |
35 | ' |
36 | ' Properties: [Declare], Name, Params, Remarks, Returns |
37 | ' Summary, Type |
38 | ' |
39 | ' Constructor: (+1 Overloads) Sub New |
40 | ' |
41 | ' Function: ToString |
42 | ' |
43 | ' Sub: LoadFromNode |
44 | ' |
45 | ' |
46 | ' /********************************************************************************/ |
47 | |
48 | #End Region |
49 | |
50 | ' Copyright (c) Bendyline LLC. All rights reserved. Licensed under the Apache License, Version 2.0. |
51 | ' You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. |
52 | |
53 | Imports System.Runtime.CompilerServices |
54 | Imports System.Xml |
55 | Imports Microsoft.VisualBasic.ApplicationServices.Development.XmlDoc.Serialization |
56 | Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel |
57 | Imports Microsoft.VisualBasic.Language |
58 | Imports Microsoft.VisualBasic.Text |
59 | |
60 | Namespace ApplicationServices.Development.XmlDoc.Assembly |
61 | |
62 | ''' <summary> |
63 | ''' Base class for a method or property. |
64 | ''' </summary> |
65 | Public Class ProjectMember |
66 | |
67 | Dim projectType As ProjectType |
68 | |
69 | Public Property Name() As String |
70 | Public Property Summary() As String |
71 | Public Property Returns() As String |
72 | Public Property Remarks As String |
73 | Public Property Params As param() |
74 | |
75 | ''' <summary> |
76 | ''' 申明的原型 |
77 | ''' </summary> |
78 | ''' <returns></returns> |
79 | Public Property [Declare] As String |
80 | |
81 | Public ReadOnly Property Type() As ProjectType |
82 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
83 | Get |
84 | Return Me.projectType |
85 | End Get |
86 | End Property |
87 | |
88 | Public Sub New(projectType As ProjectType) |
89 | Me.projectType = projectType |
90 | End Sub |
91 | |
92 | Public Overrides Function ToString() As String |
93 | Return [Declare] |
94 | End Function |
95 | |
96 | Public Sub LoadFromNode(xn As XmlNode) |
97 | Dim summaryNode As XmlNode = xn.SelectSingleNode("summary") |
98 | Dim [declare] As NamedValue(Of String) = xn _ |
99 | .Attributes _ |
100 | .GetNamedItem("name") _ |
101 | .InnerText _ |
102 | .Trim(ASCII.CR, ASCII.LF, " ") _ |
103 | .GetTagValue(":", trim:=True) |
104 | |
105 | Me.Declare = [declare].Value |
106 | |
107 | If summaryNode IsNot Nothing Then |
108 | Me.Summary = summaryNode.InnerText.Trim(ASCII.CR, ASCII.LF, " ") |
109 | End If |
110 | |
111 | Dim returnsNode As XmlNode = xn.SelectSingleNode("returns") |
112 | |
113 | If returnsNode IsNot Nothing Then |
114 | Me.Returns = returnsNode.InnerText.Trim(ASCII.CR, ASCII.LF, " ") |
115 | End If |
116 | |
117 | Dim remarksNode As XmlNode = xn.SelectSingleNode("remarks") |
118 | |
119 | If remarksNode IsNot Nothing Then |
120 | Me.Remarks = remarksNode.InnerText.Trim(ASCII.CR, ASCII.LF, " ") |
121 | End If |
122 | |
123 | Dim ns = xn.SelectNodes("param") |
124 | |
125 | If Not ns Is Nothing Then |
126 | Dim args As New List(Of param) |
127 | Dim text$ |
128 | Dim name$ |
129 | |
130 | For Each x As XmlNode In ns |
131 | text = x.InnerText Or "-".AsDefault(Function() |
132 | Return Strings.Trim(x.InnerText).StringEmpty |
133 | End Function) |
134 | name = x.Attributes _ |
135 | .GetNamedItem("name") _ |
136 | .InnerText _ |
137 | .Trim(ASCII.CR, ASCII.LF, " ") |
138 | args += New param With { |
139 | .name = name, |
140 | .text = (text) |
141 | } |
142 | Next |
143 | |
144 | Me.Params = args |
145 | End If |
146 | End Sub |
147 | End Class |
148 | End Namespace |