1- using System ;
1+ using System ;
22using System . Linq ;
33using System . Linq . Expressions ;
44using AutoMapper . Execution ;
55using static System . Linq . Expressions . Expression ;
66using static AutoMapper . Utils . ExpressionExtensions ;
77
88namespace AutoMapper . Utils
9- {
10- using AutoMapper . Internal ;
11- using AutoMapper . Internal . Mappers ;
12- using System . Collections . Generic ;
13-
9+ {
10+ using AutoMapper . Internal ;
11+ using AutoMapper . Internal . Mappers ;
12+ using System . Collections . Generic ;
13+
1414 public static class CollectionMapperExtensions
1515 {
1616 internal static Expression MapCollectionExpression ( this IGlobalConfiguration configurationProvider ,
@@ -40,7 +40,7 @@ internal static Expression MapCollectionExpression(this IGlobalConfiguration con
4040 Assign ( passedDestination , destExpression ) ,
4141 IfThenElse ( condition ?? Constant ( false ) ,
4242 Block ( Assign ( newExpression , passedDestination ) , Call ( newExpression , clearMethod ) ) ,
43- Assign ( newExpression , passedDestination . Type . NewExpr ( ifInterfaceType ) ) ) ,
43+ Assign ( newExpression , passedDestination . Type . NewExpr ( ifInterfaceType , configurationProvider ) ) ) ,
4444 Condition ( Equal ( sourceExpression , Constant ( null ) ) , ToType ( ifNullExpr , passedDestination . Type ) , ToType ( mapExpr , passedDestination . Type ) )
4545 ) ;
4646 if ( memberMap != null )
@@ -60,16 +60,16 @@ internal static Expression MapCollectionExpression(this IGlobalConfiguration con
6060 return Block ( checkContext , checkNull ) ;
6161 }
6262
63- internal static Delegate Constructor ( Type type )
63+ internal static Delegate Constructor ( Type type , IGlobalConfiguration configuration )
6464 {
65- return Lambda ( ToType ( ObjectFactory . GenerateConstructorExpression ( type ) , type ) ) . Compile ( ) ;
65+ return Lambda ( ToType ( ObjectFactory . GenerateConstructorExpression ( type , configuration ) , type ) ) . Compile ( ) ;
6666 }
6767
68- internal static Expression NewExpr ( this Type baseType , Type ifInterfaceType )
68+ internal static Expression NewExpr ( this Type baseType , Type ifInterfaceType , IGlobalConfiguration configuration )
6969 {
7070 var newExpr = baseType . IsInterface ( )
7171 ? New ( ifInterfaceType . MakeGenericType ( TypeHelper . GetElementTypes ( baseType , ElementTypeFlags . BreakKeyValuePair ) ) )
72- : ObjectFactory . GenerateConstructorExpression ( baseType ) ;
72+ : ObjectFactory . GenerateConstructorExpression ( baseType , configuration ) ;
7373 return ToType ( newExpr , baseType ) ;
7474 }
7575
@@ -117,8 +117,8 @@ internal static BinaryExpression IfNotNull(Expression destExpression)
117117 public class CollectionMapper : IObjectMapper
118118 {
119119 public bool IsMatch ( TypePair context ) => context . SourceType . IsEnumerableType ( ) && context . DestinationType . IsCollectionType ( ) ;
120-
121- public Expression MapExpression ( IGlobalConfiguration configurationProvider , ProfileMap profileMap , MemberMap memberMap , Expression sourceExpression , Expression destExpression )
122- => configurationProvider . MapCollectionExpression ( profileMap , memberMap , sourceExpression , destExpression , CollectionMapperExtensions . IfNotNull , typeof ( List < > ) , CollectionMapperExtensions . MapItemExpr ) ;
120+
121+ public Expression MapExpression ( IGlobalConfiguration configurationProvider , ProfileMap profileMap , MemberMap memberMap , Expression sourceExpression , Expression destExpression )
122+ => configurationProvider . MapCollectionExpression ( profileMap , memberMap , sourceExpression , destExpression , CollectionMapperExtensions . IfNotNull , typeof ( List < > ) , CollectionMapperExtensions . MapItemExpr ) ;
123123 }
124124}
0 commit comments