Skip to content

Commit

Permalink
Merge pull request #81 from BlaiseD/master
Browse files Browse the repository at this point in the history
cleanup.
  • Loading branch information
BlaiseD authored Jul 6, 2020
2 parents 1ae8507 + 50e29a4 commit 170294c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Authors>Jimmy Bogard</Authors>
<LangVersion>latest</LangVersion>
<VersionPrefix>4.0.0-preview01</VersionPrefix>
<VersionPrefix>4.0.0</VersionPrefix>
<WarningsAsErrors>true</WarningsAsErrors>
<NoWarn>$(NoWarn);1701;1702;1591</NoWarn>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,32 +174,22 @@ protected override Expression VisitMemberInit(MemberInitExpression node)
//The destination becomes the source because to map a source expression to a destination expression,
//we need the expressions used to create the source from the destination

//IEnumerable<MemberBinding> bindings = node.Bindings.Select
//(
// binding =>
// {
// Expression bindingExpression = ((MemberAssignment)binding).Expression;
// return DoBind
// (
// GetSourceMember(typeMap.GetPropertyMapByDestinationProperty(binding.Member.Name)),
// bindingExpression,
// this.Visit(bindingExpression)
// );
// }
//);

IEnumerable<MemberBinding> bindings = node.Bindings.Aggregate(new List<MemberBinding>(), (list, binding) =>
{
var propertyMap = typeMap.PropertyMaps.SingleOrDefault(item => item.DestinationName == binding.Member.Name);
if (propertyMap == null)
return list;

var sourceMember = GetSourceMember(propertyMap);
if (sourceMember == null)
return list;

Expression bindingExpression = ((MemberAssignment)binding).Expression;
list.Add
(
DoBind
(
GetSourceMember(propertyMap),
sourceMember,
bindingExpression,
this.Visit(bindingExpression)
)
Expand Down

0 comments on commit 170294c

Please sign in to comment.