1 #Region "Microsoft.VisualBasic::3d12500eeb4616cd2f9b2bc58e7a1c87, Microsoft.VisualBasic.Core\ComponentModel\DataSource\Property\GenericProperty.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 [Property]
35     
36     '         Constructor: (+2 OverloadsSub New
37     
38     
39     ' /********************************************************************************/
40
41 #End Region
42
43 Imports System.Runtime.CompilerServices
44 Imports System.Web.Script.Serialization
45
46 Namespace ComponentModel.DataSourceModel
47
48     ''' <summary>
49     ''' Dictionary for [<see cref="String"/>, <typeparamref name="T"/>]
50     ''' </summary>
51     ''' <typeparam name="T"></typeparam>
52     Public Class [Property](Of T) : Inherits DynamicPropertyBase(Of T)
53
54         Sub New()
55         End Sub
56
57         ''' <summary>
58         ''' New with a init property value
59         ''' </summary>
60         ''' <param name="initKey"></param>
61         ''' <param name="initValue"></param>
62         Sub New(initKey$, initValue As T)
63             Call Properties.Add(initKey, initValue)
64         End Sub
65
66         ''' <summary>
67         ''' 
68         ''' </summary>
69         ''' <returns></returns>
70         <ScriptIgnore> Public Iterator Property src As IEnumerable(Of NamedValue(Of T))
71             Get
72                 For Each x In Properties
73                     Yield New NamedValue(Of T) With {
74                         .Name = x.Key,
75                         .Value = x.Value
76                     }
77                 Next
78             End Get
79             <MethodImpl(MethodImplOptions.AggressiveInlining)>
80             Set(value As IEnumerable(Of NamedValue(Of T)))
81                 Properties = value.ToDictionary(Function(x) x.Name, Function(x) x.Value)
82             End Set
83         End Property
84     End Class
85 End Namespace