1 #Region "Microsoft.VisualBasic::2e88cf50a06be446f3d7bf4c8f9882df, Microsoft.VisualBasic.Core\ComponentModel\DataStructures\Enumerable\NamedValueList.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 NamedValueList
35     
36     '         Constructor: (+1 OverloadsSub New
37     '         FunctionToString
38     '         Operators: +
39     
40     
41     ' /********************************************************************************/
42
43 #End Region
44
45 Imports Microsoft.VisualBasic.ComponentModel.DataSourceModel
46 Imports Microsoft.VisualBasic.Language
47 Imports Microsoft.VisualBasic.Serialization.JSON
48
49 Namespace ComponentModel.Collection.Generic
50
51     Public Class NamedValueList(Of T) : Inherits List(Of NamedValue(Of T))
52
53         Sub New()
54             Call MyBase.New()
55         End Sub
56
57         Public Overrides Function ToString() As String
58             Return MyBase.Keys.GetJson
59         End Function
60
61         ''' <summary>
62         ''' This operator will makes a copy of <paramref name="table"/>
63         ''' </summary>
64         ''' <param name="table"></param>
65         ''' <param name="list"></param>
66         ''' <returns></returns>
67         Public Overloads Shared Operator +(table As Dictionary(Of String, T), list As NamedValueList(Of T)) As Dictionary(Of String, T)
68             table = New Dictionary(Of String, T)(table)
69
70             For Each item As NamedValue(Of T) In list
71                 Call table.Add(item.Name, item.Value)
72             Next
73
74             Return table
75         End Operator
76     End Class
77 End Namespace