Empty method in NestedMember
description
I stumbled upon a strange piece of code while looking for the cause of a mysterious error:
namespace Glue.Internals
{
internal partial class ObjectMemberFactory
{
private class NestedMember : ObjectMember, INestedMember
{
internal NestedMember(IObjectMemberAccessor member) : base(member, true)
{
}
public override void InvokeSet(object toInvokeOn, object toSet)
{
return;
}
}
}
}
InvokeSet does absolutely nothing. As result the target property remains unchanged. When I removed the override, my test application worked like I expexted.
I can upload the whole project if you need it, but I think a short description should do it for now.
--- Test application ---
Basically it just maps a Class1 object to a Class2 object and uses a converter to transform their properties (Class3ToClass4Converter).
Main:
Class1 c1 = new Class1() { Class3 = new Class3() };
Class2 c2 = new Class2();
var mapping = new Mapping<Class1, Class2>();
mapping.AddConverter(new Class3ToClass4Converter());
mapping.Relate(leftSide => leftSide.Class3, rightSide => rightSide.Class4);
c2 = mapping.Map(c1, c2);
if(c2.Class4 == null){
throw new Exception("Class3 not mapped to Class4");
}
Class1 to Class4 are just plain dummy classes. Class1 contains a property Class3 of type Class3. Class2 contains a property Class4 of type Class4. Class3 and Class4 are completely empty. Thats it.
The converter:
public class Class3ToClass4Converter: BaseSimpleConverter<Class3, Class4>
{
public override Class3 MapTowardsLeft(Class4 from)
{
return new Class3();
}
public override Class4 MapTowardsRight(Class3 from)
{
return new Class4();
}
}