1
- #if WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD
1
+ #if UAP10_0
2
+ using System . Collections . Generic ;
3
+ using System . Dynamic ;
4
+
5
+ namespace System . Linq . Dynamic . Core
6
+ {
7
+ /// <summary>
8
+ /// Provides a base class for dynamic objects for UAP10_0.
9
+ /// </summary>
10
+ public class DynamicClass : DynamicObject
11
+ {
12
+ readonly Dictionary < string , object > _properties = new Dictionary < string , object > ( ) ;
13
+
14
+ public DynamicClass (
15
+ KeyValuePair < string , object > _1
16
+ )
17
+ {
18
+ _properties . Add ( _1 . Key , _1 . Value ) ;
19
+ }
20
+
21
+ public DynamicClass (
22
+ KeyValuePair < string , object > _1 ,
23
+ KeyValuePair < string , object > _2
24
+ )
25
+ {
26
+ _properties . Add ( _1 . Key , _1 . Value ) ;
27
+ _properties . Add ( _2 . Key , _2 . Value ) ;
28
+ }
29
+
30
+ public DynamicClass (
31
+ KeyValuePair < string , object > _1 ,
32
+ KeyValuePair < string , object > _2 ,
33
+ KeyValuePair < string , object > _3
34
+ )
35
+ {
36
+ _properties . Add ( _1 . Key , _1 . Value ) ;
37
+ _properties . Add ( _2 . Key , _2 . Value ) ;
38
+ _properties . Add ( _3 . Key , _3 . Value ) ;
39
+ }
40
+
41
+ public DynamicClass (
42
+ KeyValuePair < string , object > _1 ,
43
+ KeyValuePair < string , object > _2 ,
44
+ KeyValuePair < string , object > _3 ,
45
+ KeyValuePair < string , object > _4
46
+ )
47
+ {
48
+ _properties . Add ( _1 . Key , _1 . Value ) ;
49
+ _properties . Add ( _2 . Key , _2 . Value ) ;
50
+ _properties . Add ( _3 . Key , _3 . Value ) ;
51
+ _properties . Add ( _4 . Key , _4 . Value ) ;
52
+ }
53
+
54
+ public DynamicClass (
55
+ KeyValuePair < string , object > _1 ,
56
+ KeyValuePair < string , object > _2 ,
57
+ KeyValuePair < string , object > _3 ,
58
+ KeyValuePair < string , object > _4 ,
59
+ KeyValuePair < string , object > _5
60
+ )
61
+ {
62
+ _properties . Add ( _1 . Key , _1 . Value ) ;
63
+ _properties . Add ( _2 . Key , _2 . Value ) ;
64
+ _properties . Add ( _3 . Key , _3 . Value ) ;
65
+ _properties . Add ( _4 . Key , _4 . Value ) ;
66
+ _properties . Add ( _5 . Key , _5 . Value ) ;
67
+ }
68
+
69
+ public DynamicClass (
70
+ KeyValuePair < string , object > _1 ,
71
+ KeyValuePair < string , object > _2 ,
72
+ KeyValuePair < string , object > _3 ,
73
+ KeyValuePair < string , object > _4 ,
74
+ KeyValuePair < string , object > _5 ,
75
+ KeyValuePair < string , object > _6
76
+ )
77
+ {
78
+ _properties . Add ( _1 . Key , _1 . Value ) ;
79
+ _properties . Add ( _2 . Key , _2 . Value ) ;
80
+ _properties . Add ( _3 . Key , _3 . Value ) ;
81
+ _properties . Add ( _4 . Key , _4 . Value ) ;
82
+ _properties . Add ( _5 . Key , _5 . Value ) ;
83
+ _properties . Add ( _6 . Key , _6 . Value ) ;
84
+ }
85
+
86
+ public DynamicClass (
87
+ KeyValuePair < string , object > _1 ,
88
+ KeyValuePair < string , object > _2 ,
89
+ KeyValuePair < string , object > _3 ,
90
+ KeyValuePair < string , object > _4 ,
91
+ KeyValuePair < string , object > _5 ,
92
+ KeyValuePair < string , object > _6 ,
93
+ KeyValuePair < string , object > _7
94
+ )
95
+ {
96
+ _properties . Add ( _1 . Key , _1 . Value ) ;
97
+ _properties . Add ( _2 . Key , _2 . Value ) ;
98
+ _properties . Add ( _3 . Key , _3 . Value ) ;
99
+ _properties . Add ( _4 . Key , _4 . Value ) ;
100
+ _properties . Add ( _5 . Key , _5 . Value ) ;
101
+ _properties . Add ( _6 . Key , _6 . Value ) ;
102
+ _properties . Add ( _7 . Key , _7 . Value ) ;
103
+ }
104
+
105
+ public DynamicClass (
106
+ KeyValuePair < string , object > _1 ,
107
+ KeyValuePair < string , object > _2 ,
108
+ KeyValuePair < string , object > _3 ,
109
+ KeyValuePair < string , object > _4 ,
110
+ KeyValuePair < string , object > _5 ,
111
+ KeyValuePair < string , object > _6 ,
112
+ KeyValuePair < string , object > _7 ,
113
+ KeyValuePair < string , object > _8
114
+ )
115
+ {
116
+ _properties . Add ( _1 . Key , _1 . Value ) ;
117
+ _properties . Add ( _2 . Key , _2 . Value ) ;
118
+ _properties . Add ( _3 . Key , _3 . Value ) ;
119
+ _properties . Add ( _4 . Key , _4 . Value ) ;
120
+ _properties . Add ( _5 . Key , _5 . Value ) ;
121
+ _properties . Add ( _6 . Key , _6 . Value ) ;
122
+ _properties . Add ( _7 . Key , _7 . Value ) ;
123
+ _properties . Add ( _8 . Key , _8 . Value ) ;
124
+ }
125
+
126
+ public DynamicClass (
127
+ KeyValuePair < string , object > _1 ,
128
+ KeyValuePair < string , object > _2 ,
129
+ KeyValuePair < string , object > _3 ,
130
+ KeyValuePair < string , object > _4 ,
131
+ KeyValuePair < string , object > _5 ,
132
+ KeyValuePair < string , object > _6 ,
133
+ KeyValuePair < string , object > _7 ,
134
+ KeyValuePair < string , object > _8 ,
135
+ KeyValuePair < string , object > _9
136
+ )
137
+ {
138
+ _properties . Add ( _1 . Key , _1 . Value ) ;
139
+ _properties . Add ( _2 . Key , _2 . Value ) ;
140
+ _properties . Add ( _3 . Key , _3 . Value ) ;
141
+ _properties . Add ( _4 . Key , _4 . Value ) ;
142
+ _properties . Add ( _5 . Key , _5 . Value ) ;
143
+ _properties . Add ( _6 . Key , _6 . Value ) ;
144
+ _properties . Add ( _7 . Key , _7 . Value ) ;
145
+ _properties . Add ( _8 . Key , _8 . Value ) ;
146
+ _properties . Add ( _9 . Key , _9 . Value ) ;
147
+ }
148
+
149
+ public object this [ string name ]
150
+ {
151
+ get
152
+ {
153
+ object result ;
154
+ if ( _properties . TryGetValue ( name , out result ) )
155
+ return result ;
156
+
157
+ return null ;
158
+ }
159
+ set
160
+ {
161
+ if ( _properties . ContainsKey ( name ) )
162
+ _properties [ name ] = value ;
163
+ else
164
+ _properties . Add ( name , value ) ;
165
+ }
166
+ }
167
+
168
+ public override IEnumerable < string > GetDynamicMemberNames ( )
169
+ {
170
+ return _properties . Keys ;
171
+ }
172
+
173
+ public override bool TryGetMember ( GetMemberBinder binder , out object result )
174
+ {
175
+ var name = binder . Name ;
176
+ _properties . TryGetValue ( name , out result ) ;
177
+
178
+ return true ;
179
+ }
180
+
181
+ public override bool TrySetMember ( SetMemberBinder binder , object value )
182
+ {
183
+ var name = binder . Name ;
184
+ if ( _properties . ContainsKey ( name ) )
185
+ _properties [ name ] = value ;
186
+ else
187
+ _properties . Add ( name , value ) ;
188
+
189
+ return true ;
190
+ }
191
+ }
192
+ }
193
+ #else
194
+ #if WINDOWS_APP || DOTNET5_1 || NETSTANDARD
2
195
using System . Reflection ;
3
196
#endif
4
-
5
197
namespace System . Linq . Dynamic . Core
6
198
{
7
199
/// <summary>
@@ -68,4 +260,5 @@ public void SetDynamicProperty(string propertyName, object value)
68
260
propInfo . SetValue ( this , value , null ) ;
69
261
}
70
262
}
71
- }
263
+ }
264
+ #endif
0 commit comments