Use extension method to map the nested objects.
This commit is contained in:
parent
36161b728c
commit
542cdb05f8
|
@ -71,8 +71,8 @@ namespace MapTo.Sources
|
||||||
if (property.TypeConverter is null)
|
if (property.TypeConverter is null)
|
||||||
{
|
{
|
||||||
builder.WriteLine(property.MappedSourcePropertyTypeName is null
|
builder.WriteLine(property.MappedSourcePropertyTypeName is null
|
||||||
? $"{property.Name} = {sourceClassParameterName}.{property.SourcePropertyName};"
|
? $"{property.Name} = {sourceClassParameterName}.{property.SourcePropertyName};"
|
||||||
: $"{property.Name} = new {property.Type}({sourceClassParameterName}.{property.SourcePropertyName});");
|
: $"{property.Name} = {sourceClassParameterName}.{property.SourcePropertyName}.To{property.Type}();");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -363,7 +363,7 @@ namespace Test
|
||||||
Prop1 = baz.Prop1;
|
Prop1 = baz.Prop1;
|
||||||
Prop2 = baz.Prop2;
|
Prop2 = baz.Prop2;
|
||||||
Prop3 = baz.Prop3;
|
Prop3 = baz.Prop3;
|
||||||
InnerProp1 = new B(baz.InnerProp1);
|
InnerProp1 = baz.InnerProp1.ToB();
|
||||||
}
|
}
|
||||||
".Trim();
|
".Trim();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue