@@ -27,8 +27,7 @@ private static Dictionary<Type, ConvertInstanceDelegate> TranslateICollectionCac
27
27
28
28
public static object TranslateToGenericICollectionCache ( object from , Type toInstanceOfType , Type elementType )
29
29
{
30
- ConvertInstanceDelegate translateToFn ;
31
- if ( TranslateICollectionCache . TryGetValue ( toInstanceOfType , out translateToFn ) )
30
+ if ( TranslateICollectionCache . TryGetValue ( toInstanceOfType , out var translateToFn ) )
32
31
return translateToFn ( from , toInstanceOfType ) ;
33
32
34
33
var genericType = typeof ( TranslateListWithElements < > ) . MakeGenericType ( elementType ) ;
@@ -39,8 +38,9 @@ public static object TranslateToGenericICollectionCache(object from, Type toInst
39
38
do
40
39
{
41
40
snapshot = TranslateICollectionCache ;
42
- newCache = new Dictionary < Type , ConvertInstanceDelegate > ( TranslateICollectionCache ) ;
43
- newCache [ elementType ] = translateToFn ;
41
+ newCache = new Dictionary < Type , ConvertInstanceDelegate > ( TranslateICollectionCache ) {
42
+ [ elementType ] = translateToFn
43
+ } ;
44
44
45
45
} while ( ! ReferenceEquals (
46
46
Interlocked . CompareExchange ( ref TranslateICollectionCache , newCache , snapshot ) , snapshot ) ) ;
@@ -55,8 +55,7 @@ public static object TranslateToConvertibleGenericICollectionCache(
55
55
object from , Type toInstanceOfType , Type fromElementType )
56
56
{
57
57
var typeKey = new ConvertibleTypeKey ( toInstanceOfType , fromElementType ) ;
58
- ConvertInstanceDelegate translateToFn ;
59
- if ( TranslateConvertibleICollectionCache . TryGetValue ( typeKey , out translateToFn ) ) return translateToFn ( from , toInstanceOfType ) ;
58
+ if ( TranslateConvertibleICollectionCache . TryGetValue ( typeKey , out var translateToFn ) ) return translateToFn ( from , toInstanceOfType ) ;
60
59
61
60
var toElementType = toInstanceOfType . FirstGenericType ( ) . GetGenericArguments ( ) [ 0 ] ;
62
61
var genericType = typeof ( TranslateListWithConvertibleElements < , > ) . MakeGenericType ( fromElementType , toElementType ) ;
@@ -67,8 +66,9 @@ public static object TranslateToConvertibleGenericICollectionCache(
67
66
do
68
67
{
69
68
snapshot = TranslateConvertibleICollectionCache ;
70
- newCache = new Dictionary < ConvertibleTypeKey , ConvertInstanceDelegate > ( TranslateConvertibleICollectionCache ) ;
71
- newCache [ typeKey ] = translateToFn ;
69
+ newCache = new Dictionary < ConvertibleTypeKey , ConvertInstanceDelegate > ( TranslateConvertibleICollectionCache ) {
70
+ [ typeKey ] = translateToFn
71
+ } ;
72
72
73
73
} while ( ! ReferenceEquals (
74
74
Interlocked . CompareExchange ( ref TranslateConvertibleICollectionCache , newCache , snapshot ) , snapshot ) ) ;
@@ -109,23 +109,23 @@ public static object TryTranslateCollections(Type fromPropertyType, Type toPrope
109
109
public class ConvertibleTypeKey
110
110
{
111
111
public Type ToInstanceType { get ; set ; }
112
- public Type FromElemenetType { get ; set ; }
112
+ public Type FromElementType { get ; set ; }
113
113
114
114
public ConvertibleTypeKey ( )
115
115
{
116
116
}
117
117
118
- public ConvertibleTypeKey ( Type toInstanceType , Type fromElemenetType )
118
+ public ConvertibleTypeKey ( Type toInstanceType , Type fromElementType )
119
119
{
120
120
ToInstanceType = toInstanceType ;
121
- FromElemenetType = fromElemenetType ;
121
+ FromElementType = fromElementType ;
122
122
}
123
123
124
124
public bool Equals ( ConvertibleTypeKey other )
125
125
{
126
126
if ( ReferenceEquals ( null , other ) ) return false ;
127
127
if ( ReferenceEquals ( this , other ) ) return true ;
128
- return Equals ( other . ToInstanceType , ToInstanceType ) && Equals ( other . FromElemenetType , FromElemenetType ) ;
128
+ return other . ToInstanceType == ToInstanceType && other . FromElementType == FromElementType ;
129
129
}
130
130
131
131
public override bool Equals ( object obj )
@@ -141,7 +141,7 @@ public override int GetHashCode()
141
141
unchecked
142
142
{
143
143
return ( ( ToInstanceType != null ? ToInstanceType . GetHashCode ( ) : 0 ) * 397 )
144
- ^ ( FromElemenetType != null ? FromElemenetType . GetHashCode ( ) : 0 ) ;
144
+ ^ ( FromElementType != null ? FromElementType . GetHashCode ( ) : 0 ) ;
145
145
}
146
146
}
147
147
}
0 commit comments