3
3
// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
4
4
// https://github.com/JoshClose/CsvHelper
5
5
using System . Collections ;
6
- using System . Diagnostics . CodeAnalysis ;
7
6
using System . Dynamic ;
8
7
using System . Linq . Expressions ;
9
8
using System . Reflection ;
10
9
11
10
namespace CsvHelper ;
12
11
13
- internal class FastDynamicObject : IDynamicMetaObjectProvider , IDictionary < string , object >
12
+ internal class FastDynamicObject : IDynamicMetaObjectProvider , IDictionary < string , object ? >
14
13
{
15
- private readonly Dictionary < string , object > dict ;
14
+ private readonly Dictionary < string , object ? > dict ;
16
15
17
16
public FastDynamicObject ( )
18
17
{
19
- dict = new Dictionary < string , object > ( ) ;
18
+ dict = new Dictionary < string , object ? > ( ) ;
20
19
}
21
20
22
- object IDictionary < string , object > . this [ string key ]
21
+ object ? IDictionary < string , object ? > . this [ string key ]
23
22
{
24
23
get
25
24
{
@@ -37,15 +36,15 @@ object IDictionary<string, object>.this[string key]
37
36
}
38
37
}
39
38
40
- ICollection < string > IDictionary < string , object > . Keys => dict . Keys ;
39
+ ICollection < string > IDictionary < string , object ? > . Keys => dict . Keys ;
41
40
42
- ICollection < object > IDictionary < string , object > . Values => dict . Values ;
41
+ ICollection < object ? > IDictionary < string , object ? > . Values => dict . Values ;
43
42
44
- int ICollection < KeyValuePair < string , object > > . Count => dict . Count ;
43
+ int ICollection < KeyValuePair < string , object ? > > . Count => dict . Count ;
45
44
46
- bool ICollection < KeyValuePair < string , object > > . IsReadOnly => false ;
45
+ bool ICollection < KeyValuePair < string , object ? > > . IsReadOnly => false ;
47
46
48
- object SetValue ( string key , object value )
47
+ object ? SetValue ( string key , object ? value )
49
48
{
50
49
dict [ key ] = value ;
51
50
@@ -57,32 +56,32 @@ DynamicMetaObject IDynamicMetaObjectProvider.GetMetaObject(Expression parameter)
57
56
return new FastDynamicMetaObject ( parameter , BindingRestrictions . Empty , this ) ;
58
57
}
59
58
60
- void IDictionary < string , object > . Add ( string key , object value )
59
+ void IDictionary < string , object ? > . Add ( string key , object ? value )
61
60
{
62
61
SetValue ( key , value ) ;
63
62
}
64
63
65
- void ICollection < KeyValuePair < string , object > > . Add ( KeyValuePair < string , object > item )
64
+ void ICollection < KeyValuePair < string , object ? > > . Add ( KeyValuePair < string , object ? > item )
66
65
{
67
66
SetValue ( item . Key , item . Value ) ;
68
67
}
69
68
70
- void ICollection < KeyValuePair < string , object > > . Clear ( )
69
+ void ICollection < KeyValuePair < string , object ? > > . Clear ( )
71
70
{
72
71
dict . Clear ( ) ;
73
72
}
74
73
75
- bool ICollection < KeyValuePair < string , object > > . Contains ( KeyValuePair < string , object > item )
74
+ bool ICollection < KeyValuePair < string , object ? > > . Contains ( KeyValuePair < string , object ? > item )
76
75
{
77
76
return dict . Contains ( item ) ;
78
77
}
79
78
80
- bool IDictionary < string , object > . ContainsKey ( string key )
79
+ bool IDictionary < string , object ? > . ContainsKey ( string key )
81
80
{
82
81
return dict . ContainsKey ( key ) ;
83
82
}
84
83
85
- void ICollection < KeyValuePair < string , object > > . CopyTo ( KeyValuePair < string , object > [ ] array , int arrayIndex )
84
+ void ICollection < KeyValuePair < string , object ? > > . CopyTo ( KeyValuePair < string , object ? > [ ] array , int arrayIndex )
86
85
{
87
86
if ( arrayIndex < 0 || arrayIndex >= array . Length )
88
87
{
@@ -102,7 +101,7 @@ void ICollection<KeyValuePair<string, object>>.CopyTo(KeyValuePair<string, objec
102
101
}
103
102
}
104
103
105
- IEnumerator < KeyValuePair < string , object > > IEnumerable < KeyValuePair < string , object > > . GetEnumerator ( )
104
+ IEnumerator < KeyValuePair < string , object ? > > IEnumerable < KeyValuePair < string , object ? > > . GetEnumerator ( )
106
105
{
107
106
return dict . GetEnumerator ( ) ;
108
107
}
@@ -112,24 +111,24 @@ IEnumerator IEnumerable.GetEnumerator()
112
111
return dict . GetEnumerator ( ) ;
113
112
}
114
113
115
- bool IDictionary < string , object > . Remove ( string key )
114
+ bool IDictionary < string , object ? > . Remove ( string key )
116
115
{
117
116
return dict . Remove ( key ) ;
118
117
}
119
118
120
- bool ICollection < KeyValuePair < string , object > > . Remove ( KeyValuePair < string , object > item )
119
+ bool ICollection < KeyValuePair < string , object ? > > . Remove ( KeyValuePair < string , object ? > item )
121
120
{
122
121
return dict . Remove ( item . Key ) ;
123
122
}
124
123
125
- bool IDictionary < string , object > . TryGetValue ( string key , out object value )
124
+ bool IDictionary < string , object ? > . TryGetValue ( string key , out object ? value )
126
125
{
127
126
return dict . TryGetValue ( key , out value ! ) ;
128
127
}
129
128
130
129
private class FastDynamicMetaObject : DynamicMetaObject
131
130
{
132
- private static readonly MethodInfo getValueMethod = typeof ( IDictionary < string , object > ) . GetProperty ( "Item" ) ! . GetGetMethod ( ) ! ;
131
+ private static readonly MethodInfo getValueMethod = typeof ( IDictionary < string , object ? > ) . GetProperty ( "Item" ) ! . GetGetMethod ( ) ! ;
133
132
private static readonly MethodInfo setValueMethod = typeof ( FastDynamicObject ) . GetMethod ( "SetValue" , BindingFlags . NonPublic | BindingFlags . Instance ) ! ;
134
133
135
134
public FastDynamicMetaObject ( Expression expression , BindingRestrictions restrictions ) : base ( expression , restrictions ) { }
@@ -165,7 +164,7 @@ public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, Dy
165
164
166
165
public override IEnumerable < string > GetDynamicMemberNames ( )
167
166
{
168
- if ( HasValue && Value is IDictionary < string , object > lookup )
167
+ if ( HasValue && Value is IDictionary < string , object ? > lookup )
169
168
{
170
169
return lookup . Keys ;
171
170
}
0 commit comments