@@ -31,11 +31,11 @@ public XpressionMapperVisitor(IMapper mapper, IConfigurationProvider configurati
3131
3232 protected IMapper Mapper { get ; }
3333
34- protected override Expression VisitParameter ( ParameterExpression parameterExpression )
34+ protected override Expression VisitParameter ( ParameterExpression node )
3535 {
36- InfoDictionary . Add ( parameterExpression , TypeMappings ) ;
37- var pair = InfoDictionary . SingleOrDefault ( a => a . Key . Equals ( parameterExpression ) ) ;
38- return ! pair . Equals ( default ( KeyValuePair < Type , MapperInfo > ) ) ? pair . Value . NewParameter : base . VisitParameter ( parameterExpression ) ;
36+ InfoDictionary . Add ( node , TypeMappings ) ;
37+ var pair = InfoDictionary . SingleOrDefault ( a => a . Key . Equals ( node ) ) ;
38+ return ! pair . Equals ( default ( KeyValuePair < Type , MapperInfo > ) ) ? pair . Value . NewParameter : base . VisitParameter ( node ) ;
3939 }
4040
4141 protected override Expression VisitMember ( MemberExpression node )
@@ -328,54 +328,54 @@ protected void FindDestinationFullName(Type typeSource, Type typeDestination, st
328328 PathMap pathMap = typeMap . FindPathMapByDestinationPath ( destinationFullPath : sourceFullName ) ;
329329 if ( pathMap != null )
330330 {
331- propertyMapInfoList . Add ( new PropertyMapInfo ( pathMap . SourceExpression , new List < MemberInfo > ( ) ) ) ;
331+ propertyMapInfoList . Add ( new PropertyMapInfo ( pathMap . CustomMapExpression , new List < MemberInfo > ( ) ) ) ;
332332 return ;
333333 }
334334
335335
336336 if ( sourceFullName . IndexOf ( period , StringComparison . OrdinalIgnoreCase ) < 0 )
337337 {
338338 var propertyMap = typeMap . GetPropertyMapByDestinationProperty ( sourceFullName ) ;
339- var sourceMemberInfo = typeSource . GetFieldOrProperty ( propertyMap . DestinationProperty . Name ) ;
339+ var sourceMemberInfo = typeSource . GetFieldOrProperty ( propertyMap . DestinationMember . Name ) ;
340340 if ( propertyMap . ValueResolverConfig != null )
341341 {
342342 throw new InvalidOperationException ( Resource . customResolversNotSupported ) ;
343343 }
344344
345- if ( propertyMap . CustomExpression == null && ! propertyMap . SourceMembers . Any ( ) )
345+ if ( propertyMap . CustomMapExpression == null && ! propertyMap . SourceMembers . Any ( ) )
346346 throw new InvalidOperationException ( string . Format ( CultureInfo . CurrentCulture , Resource . srcMemberCannotBeNullFormat , typeSource . Name , typeDestination . Name , sourceFullName ) ) ;
347347
348348 CompareSourceAndDestLiterals
349349 (
350- propertyMap . CustomExpression != null ? propertyMap . CustomExpression . ReturnType : propertyMap . SourceMember . GetMemberType ( ) ,
351- propertyMap . CustomExpression != null ? propertyMap . CustomExpression . ToString ( ) : propertyMap . SourceMember . Name ,
350+ propertyMap . CustomMapExpression != null ? propertyMap . CustomMapExpression . ReturnType : propertyMap . SourceMember . GetMemberType ( ) ,
351+ propertyMap . CustomMapExpression != null ? propertyMap . CustomMapExpression . ToString ( ) : propertyMap . SourceMember . Name ,
352352 sourceMemberInfo . GetMemberType ( )
353353 ) ;
354354
355355 void CompareSourceAndDestLiterals ( Type mappedPropertyType , string mappedPropertyDescription , Type sourceMemberType )
356356 {
357357 //switch from IsValueType to IsLiteralType because we do not want to throw an exception for all structs
358358 if ( ( mappedPropertyType . IsLiteralType ( ) || sourceMemberType . IsLiteralType ( ) ) && sourceMemberType != mappedPropertyType )
359- throw new InvalidOperationException ( string . Format ( CultureInfo . CurrentCulture , Resource . expressionMapValueTypeMustMatchFormat , mappedPropertyType . Name , mappedPropertyDescription , sourceMemberType . Name , propertyMap . DestinationProperty . Name ) ) ;
359+ throw new InvalidOperationException ( string . Format ( CultureInfo . CurrentCulture , Resource . expressionMapValueTypeMustMatchFormat , mappedPropertyType . Name , mappedPropertyDescription , sourceMemberType . Name , propertyMap . DestinationMember . Name ) ) ;
360360 }
361361
362- propertyMapInfoList . Add ( new PropertyMapInfo ( propertyMap . CustomExpression , propertyMap . SourceMembers . ToList ( ) ) ) ;
362+ propertyMapInfoList . Add ( new PropertyMapInfo ( propertyMap . CustomMapExpression , propertyMap . SourceMembers . ToList ( ) ) ) ;
363363 }
364364 else
365365 {
366366 var propertyName = sourceFullName . Substring ( 0 , sourceFullName . IndexOf ( period , StringComparison . OrdinalIgnoreCase ) ) ;
367367 var propertyMap = typeMap . GetPropertyMapByDestinationProperty ( propertyName ) ;
368368
369- var sourceMemberInfo = typeSource . GetFieldOrProperty ( propertyMap . DestinationProperty . Name ) ;
370- if ( propertyMap . CustomExpression == null && ! propertyMap . SourceMembers . Any ( ) ) //If sourceFullName has a period then the SourceMember cannot be null. The SourceMember is required to find the ProertyMap of its child object.
369+ var sourceMemberInfo = typeSource . GetFieldOrProperty ( propertyMap . DestinationMember . Name ) ;
370+ if ( propertyMap . CustomMapExpression == null && ! propertyMap . SourceMembers . Any ( ) ) //If sourceFullName has a period then the SourceMember cannot be null. The SourceMember is required to find the ProertyMap of its child object.
371371 throw new InvalidOperationException ( string . Format ( CultureInfo . CurrentCulture , Resource . srcMemberCannotBeNullFormat , typeSource . Name , typeDestination . Name , propertyName ) ) ;
372372
373- propertyMapInfoList . Add ( new PropertyMapInfo ( propertyMap . CustomExpression , propertyMap . SourceMembers . ToList ( ) ) ) ;
373+ propertyMapInfoList . Add ( new PropertyMapInfo ( propertyMap . CustomMapExpression , propertyMap . SourceMembers . ToList ( ) ) ) ;
374374 var childFullName = sourceFullName . Substring ( sourceFullName . IndexOf ( period , StringComparison . OrdinalIgnoreCase ) + 1 ) ;
375375
376- FindDestinationFullName ( sourceMemberInfo . GetMemberType ( ) , propertyMap . CustomExpression == null
376+ FindDestinationFullName ( sourceMemberInfo . GetMemberType ( ) , propertyMap . CustomMapExpression == null
377377 ? propertyMap . SourceMember . GetMemberType ( )
378- : propertyMap . CustomExpression . ReturnType , childFullName , propertyMapInfoList ) ;
378+ : propertyMap . CustomMapExpression . ReturnType , childFullName , propertyMapInfoList ) ;
379379 }
380380 }
381381 }
0 commit comments