@@ -1400,40 +1400,30 @@ private Expression CreateNewExpression(List<DynamicProperty> properties, List<Ex
1400
1400
1401
1401
if ( type == null )
1402
1402
{
1403
- #if ! UAP10_0
1404
- if ( _parsingConfig != null && _parsingConfig . UseDynamicObjectClassForAnonymousTypes )
1405
- {
1406
- #endif
1407
- type = typeof ( DynamicClass ) ;
1408
- Type typeForKeyValuePair = typeof ( KeyValuePair < string , object > ) ;
1409
- #if NET35 || NET40
1410
- ConstructorInfo constructorForKeyValuePair = typeForKeyValuePair . GetConstructors ( ) . First ( ) ;
1411
- #else
1412
- ConstructorInfo constructorForKeyValuePair = typeForKeyValuePair . GetTypeInfo ( ) . DeclaredConstructors . First ( ) ;
1413
- #endif
1414
- var arrayIndexParams = new List < Expression > ( ) ;
1415
- for ( int i = 0 ; i < expressions . Count ; i ++ )
1416
- {
1417
- // Just convert the expression always to an object expression.
1418
- UnaryExpression boxingExpression = Expression . Convert ( expressions [ i ] , typeof ( object ) ) ;
1419
- NewExpression parameter = Expression . New ( constructorForKeyValuePair , ( Expression ) Expression . Constant ( properties [ i ] . Name ) , boxingExpression ) ;
1403
+ #if UAP10_0
1404
+ type = typeof ( DynamicClass ) ;
1405
+ Type typeForKeyValuePair = typeof ( KeyValuePair < string , object > ) ;
1420
1406
1421
- arrayIndexParams . Add ( parameter ) ;
1422
- }
1407
+ ConstructorInfo constructorForKeyValuePair = typeForKeyValuePair . GetTypeInfo ( ) . DeclaredConstructors . First ( ) ;
1423
1408
1424
- // Create an expression tree that represents creating and initializing a one-dimensional array of type KeyValuePair<string, object>.
1425
- NewArrayExpression newArrayExpression = Expression . NewArrayInit ( typeof ( KeyValuePair < string , object > ) , arrayIndexParams ) ;
1409
+ var arrayIndexParams = new List < Expression > ( ) ;
1410
+ for ( int i = 0 ; i < expressions . Count ; i ++ )
1411
+ {
1412
+ // Just convert the expression always to an object expression.
1413
+ UnaryExpression boxingExpression = Expression . Convert ( expressions [ i ] , typeof ( object ) ) ;
1414
+ NewExpression parameter = Expression . New ( constructorForKeyValuePair , ( Expression ) Expression . Constant ( properties [ i ] . Name ) , boxingExpression ) ;
1426
1415
1427
- // Get the "public DynamicClass(KeyValuePair<string, object>[] propertylist)" constructor
1428
- #if NET35 || NET40
1429
- ConstructorInfo constructor = type . GetConstructors ( ) . First ( ) ;
1430
- #else
1431
- ConstructorInfo constructor = type . GetTypeInfo ( ) . DeclaredConstructors . First ( ) ;
1432
- #endif
1433
- return Expression . New ( constructor , newArrayExpression ) ;
1434
- #if ! UAP10_0
1416
+ arrayIndexParams . Add ( parameter ) ;
1435
1417
}
1436
1418
1419
+ // Create an expression tree that represents creating and initializing a one-dimensional array of type KeyValuePair<string, object>.
1420
+ NewArrayExpression newArrayExpression = Expression . NewArrayInit ( typeof ( KeyValuePair < string , object > ) , arrayIndexParams ) ;
1421
+
1422
+ // Get the "public DynamicClass(KeyValuePair<string, object>[] propertylist)" constructor
1423
+ ConstructorInfo constructor = type . GetTypeInfo ( ) . DeclaredConstructors . First ( ) ;
1424
+
1425
+ return Expression . New ( constructor , newArrayExpression ) ;
1426
+ #else
1437
1427
type = DynamicClassFactory . CreateType ( properties , _createParameterCtor ) ;
1438
1428
#endif
1439
1429
}
@@ -1454,7 +1444,6 @@ private Expression CreateNewExpression(List<DynamicProperty> properties, List<Ex
1454
1444
for ( int i = 0 ; i < propertyTypes . Length ; i ++ )
1455
1445
{
1456
1446
Type propertyType = propertyTypes [ i ] ;
1457
- // Type expressionType = expressions[i].Type;
1458
1447
1459
1448
// Promote from Type to Nullable Type if needed
1460
1449
expressionsPromoted . Add ( _parsingConfig . ExpressionPromoter . Promote ( expressions [ i ] , propertyType , true , true ) ) ;
@@ -1468,7 +1457,6 @@ private Expression CreateNewExpression(List<DynamicProperty> properties, List<Ex
1468
1457
{
1469
1458
PropertyInfo property = type . GetProperty ( properties [ i ] . Name ) ;
1470
1459
Type propertyType = property . PropertyType ;
1471
- // Type expressionType = expressions[i].Type;
1472
1460
1473
1461
// Promote from Type to Nullable Type if needed
1474
1462
bindings [ i ] = Expression . Bind ( property , _parsingConfig . ExpressionPromoter . Promote ( expressions [ i ] , propertyType , true , true ) ) ;
0 commit comments