@@ -211,8 +211,15 @@ protected static Delegate GetGetMethod(PropertyInfo property, Type propertyType)
211
211
}
212
212
}
213
213
214
- private sealed class ReferenceTypeHelper < TContainer > : TypeHelper where TContainer : class ?
214
+ private sealed class ReferenceTypeHelper < TContainer > : TypeHelper where TContainer : class
215
215
{
216
+ private static Func < TContainer , TProperty > GetGetMethod < TProperty > ( PropertyInfo property ) where TProperty : struct =>
217
+ #if ES_BUILD_STANDALONE
218
+ ( Func < TContainer , TProperty > ) property . GetMethod ! . CreateDelegate ( typeof ( Func < TContainer , TProperty > ) ) ;
219
+ #else
220
+ property . GetMethod ! . CreateDelegate < Func < TContainer , TProperty > > ( ) ;
221
+ #endif
222
+
216
223
public override Func < PropertyValue , PropertyValue > GetPropertyGetter ( PropertyInfo property )
217
224
{
218
225
Type type = property . PropertyType ;
@@ -227,25 +234,25 @@ public override Func<PropertyValue, PropertyValue> GetPropertyGetter(PropertyInf
227
234
if ( type . IsEnum )
228
235
type = Enum . GetUnderlyingType ( type ) ;
229
236
230
- if ( type == typeof ( bool ) ) { var f = ( Func < TContainer , bool > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
231
- if ( type == typeof ( byte ) ) { var f = ( Func < TContainer , byte > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
232
- if ( type == typeof ( sbyte ) ) { var f = ( Func < TContainer , sbyte > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
233
- if ( type == typeof ( char ) ) { var f = ( Func < TContainer , char > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
234
- if ( type == typeof ( short ) ) { var f = ( Func < TContainer , short > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
235
- if ( type == typeof ( ushort ) ) { var f = ( Func < TContainer , ushort > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
236
- if ( type == typeof ( int ) ) { var f = ( Func < TContainer , int > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
237
- if ( type == typeof ( uint ) ) { var f = ( Func < TContainer , uint > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
238
- if ( type == typeof ( long ) ) { var f = ( Func < TContainer , long > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
239
- if ( type == typeof ( ulong ) ) { var f = ( Func < TContainer , ulong > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
240
- if ( type == typeof ( IntPtr ) ) { var f = ( Func < TContainer , IntPtr > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
241
- if ( type == typeof ( UIntPtr ) ) { var f = ( Func < TContainer , UIntPtr > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
242
- if ( type == typeof ( float ) ) { var f = ( Func < TContainer , float > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
243
- if ( type == typeof ( double ) ) { var f = ( Func < TContainer , double > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
244
- if ( type == typeof ( Guid ) ) { var f = ( Func < TContainer , Guid > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
245
- if ( type == typeof ( DateTime ) ) { var f = ( Func < TContainer , DateTime > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
246
- if ( type == typeof ( DateTimeOffset ) ) { var f = ( Func < TContainer , DateTimeOffset > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
247
- if ( type == typeof ( TimeSpan ) ) { var f = ( Func < TContainer , TimeSpan > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
248
- if ( type == typeof ( decimal ) ) { var f = ( Func < TContainer , decimal > ) GetGetMethod ( property , type ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
237
+ if ( type == typeof ( bool ) ) { var f = GetGetMethod < bool > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
238
+ if ( type == typeof ( byte ) ) { var f = GetGetMethod < byte > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
239
+ if ( type == typeof ( sbyte ) ) { var f = GetGetMethod < sbyte > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
240
+ if ( type == typeof ( char ) ) { var f = GetGetMethod < char > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
241
+ if ( type == typeof ( short ) ) { var f = GetGetMethod < short > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
242
+ if ( type == typeof ( ushort ) ) { var f = GetGetMethod < ushort > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
243
+ if ( type == typeof ( int ) ) { var f = GetGetMethod < int > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
244
+ if ( type == typeof ( uint ) ) { var f = GetGetMethod < uint > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
245
+ if ( type == typeof ( long ) ) { var f = GetGetMethod < long > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
246
+ if ( type == typeof ( ulong ) ) { var f = GetGetMethod < ulong > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
247
+ if ( type == typeof ( IntPtr ) ) { var f = GetGetMethod < IntPtr > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
248
+ if ( type == typeof ( UIntPtr ) ) { var f = GetGetMethod < UIntPtr > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
249
+ if ( type == typeof ( float ) ) { var f = GetGetMethod < float > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
250
+ if ( type == typeof ( double ) ) { var f = GetGetMethod < double > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
251
+ if ( type == typeof ( Guid ) ) { var f = GetGetMethod < Guid > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
252
+ if ( type == typeof ( DateTime ) ) { var f = GetGetMethod < DateTime > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
253
+ if ( type == typeof ( DateTimeOffset ) ) { var f = GetGetMethod < DateTimeOffset > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
254
+ if ( type == typeof ( TimeSpan ) ) { var f = GetGetMethod < TimeSpan > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
255
+ if ( type == typeof ( decimal ) ) { var f = GetGetMethod < decimal > ( property ) ; return container => new PropertyValue ( f ( ( TContainer ) container . ReferenceValue ! ) ) ; }
249
256
250
257
return container => new PropertyValue ( property . GetValue ( container . ReferenceValue ) ) ;
251
258
}
0 commit comments