1 | #Region "Microsoft.VisualBasic::8d0f081e14d2893267ea78104f86e6dc, Microsoft.VisualBasic.Core\Language\Linq\LanguageExtensions.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 | ' Module LanguageExtensions |
35 | ' |
36 | ' Sub: (+5 Overloads) Add |
37 | ' |
38 | ' |
39 | ' /********************************************************************************/ |
40 | |
41 | #End Region |
42 | |
43 | Imports System.Runtime.CompilerServices |
44 | Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel |
45 | Imports Microsoft.VisualBasic.ComponentModel.Ranges.Model |
46 | Imports Microsoft.VisualBasic.Text.Xml.Models |
47 | |
48 | Namespace Language |
49 | |
50 | ''' <summary> |
51 | ''' <see cref="List(Of T)"/> initizlize syntax supports |
52 | ''' </summary> |
53 | Public Module LanguageExtensions |
54 | |
55 | ''' <summary> |
56 | ''' New List From syntax supports |
57 | ''' |
58 | ''' ``` |
59 | ''' {Name, value, Description?} |
60 | ''' ``` |
61 | ''' </summary> |
62 | ''' |
63 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
64 | <Extension> Public Sub Add(Of T)(list As List(Of NamedValue(Of T)), name$, value As T, Optional descript$ = Nothing) |
65 | list += New NamedValue(Of T) With { |
66 | .Name = name, |
67 | .Value = value, |
68 | .Description = descript |
69 | } |
70 | End Sub |
71 | |
72 | ''' <summary> |
73 | ''' From {"1,100", "100,1000", "200,500"} |
74 | ''' </summary> |
75 | ''' <param name="list"></param> |
76 | ''' <param name="range$"></param> |
77 | ''' |
78 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
79 | <Extension> Public Sub Add(list As List(Of IntRange), range$) |
80 | list += range |
81 | End Sub |
82 | |
83 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
84 | <Extension> Public Sub Add(list As List(Of DoubleRange), range$) |
85 | list += range |
86 | End Sub |
87 | |
88 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
89 | <Extension> |
90 | Public Sub Add(list As List(Of NamedValue), name$, value$) |
91 | list += New NamedValue With { |
92 | .name = name, |
93 | .text = value |
94 | } |
95 | End Sub |
96 | |
97 | <MethodImpl(MethodImplOptions.AggressiveInlining)> |
98 | <Extension> |
99 | Public Sub Add(list As List(Of [Property]), name$, value$, Optional comment$ = Nothing) |
100 | list += New [Property] With { |
101 | .name = name, |
102 | .value = value, |
103 | .Comment = comment |
104 | } |
105 | End Sub |
106 | End Module |
107 | End Namespace |