New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow ignores on reverse map paths #2162
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,11 @@ public void MapFrom<TSourceMember>(Expression<Func<TSource, TSourceMember>> sour | |
MapFromUntyped(sourceExpression); | ||
} | ||
|
||
public void Ignore() | ||
{ | ||
PathMapActions.Add(pm => pm.Ignored = true); | ||
} | ||
|
||
public void MapFromUntyped(LambdaExpression sourceExpression) | ||
{ | ||
_sourceExpression = sourceExpression; | ||
|
@@ -39,14 +44,6 @@ public void MapFromUntyped(LambdaExpression sourceExpression) | |
|
||
public void Configure(TypeMap typeMap) | ||
{ | ||
//var destMember = DestinationMember; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a reminder that I left smth out, but I guess somebody will eventually complain. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ha, should we open another GH issue then? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather wait, but if you feel it matters right now... |
||
|
||
//if(destMember.DeclaringType.IsGenericType()) | ||
//{ | ||
// var destTypeInfo = typeMap.Profile.CreateTypeDetails(destMember.DeclaringType); | ||
// destMember = destTypeInfo.PublicReadAccessors.Single(m => m.Name == destMember.Name); | ||
//} | ||
|
||
var pathMap = typeMap.FindOrCreatePathMapFor(_destinationExpression, MemberPath, typeMap); | ||
|
||
Apply(pathMap); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is simple enough, but there is some duplication here. We could just copy Ignored to PropertyMap.Ignored and handle both cases (PathMaps and PropertyMaps) in TryPopertyMap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That might take a bit more refactoring I think, since that method returns an expression and the PropertyMap piece above in
CreateAssignmentFunc
does a similar filter.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you would have to return null when CanResolve is false and filter for that.