Skip to content

Commit

Permalink
Refactored CloneProperties in ReflectionHelper.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sony Arouje committed May 29, 2012
1 parent bb16e59 commit 27160ad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
10 changes: 1 addition & 9 deletions Net.Graph.Neo4JD/EntityMapper/ReflectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,7 @@ public object CloneProperties(object origin, object destination)
foreach (var destinationProperty in destination.GetType().GetProperties())
{
if (destinationProperty.CanWrite)
{
foreach (var originProperty in origin.GetType().GetProperties())
{
if (originProperty.CanRead && (originProperty.Name == destinationProperty.Name && originProperty.PropertyType == destinationProperty.PropertyType))
{
destinationProperty.SetValue(destination, originProperty.GetValue(origin, null), null);
}
}
}
destinationProperty.SetValue(destination, origin.GetType().GetProperty(destinationProperty.Name).GetValue(origin, null), null);
}

return destination;
Expand Down
Binary file modified Net.Graph.Neo4jD.suo
Binary file not shown.
7 changes: 6 additions & 1 deletion Test.Neo4JD/EntityMappingTest/InheritedEntityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,14 @@ public void Get_MyClassEntity_And_Update_Manager()
MyClass myClaz = nodeMapper.Get<MyClass>(29);
Console.WriteLine("Get_MyClassEntity_And_Update_Manager: " + myClaz.GetType().ToString());
Manager manager = (Manager)myClaz.SelectedPerson;
manager.OfficeName = "Sony Arouje";
manager.OfficeName = "Product Development";
myClaz.SelectedPerson = manager;
nodeMapper.Save<MyClass>(myClaz);


MyClass myClazTmp = nodeMapper.Get<MyClass>(29);
Manager managerTmp = (Manager)myClaz.SelectedPerson;
Assert.AreEqual("Product Development", manager.OfficeName);
}
}
}

0 comments on commit 27160ad

Please sign in to comment.