-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support mapping to target readonly collections (#252)
Introduces a new concept of ExistingTargetMappings, which are mappings which map to an existing target. Currently only Collection-, Dictionary- and ObjectPropertyMappings support existing target mappings. For an object property an existing target mapping is tried to be built if it the source and target property is readable, but the target property is not setable.
- Loading branch information
Showing
75 changed files
with
1,326 additions
and
512 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
src/Riok.Mapperly/Descriptors/MappingBodyBuilder/UserMethodMappingBodyBuilder.cs
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
src/Riok.Mapperly/Descriptors/MappingBodyBuilders/MappingBodyBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Riok.Mapperly.Descriptors.Mappings; | ||
using Riok.Mapperly.Descriptors.Mappings.ExistingTarget; | ||
using Riok.Mapperly.Descriptors.Mappings.PropertyMappings; | ||
|
||
namespace Riok.Mapperly.Descriptors.MappingBodyBuilders; | ||
|
||
public class MappingBodyBuilder | ||
{ | ||
private readonly MappingCollection _mappings; | ||
|
||
public MappingBodyBuilder(MappingCollection mappings) | ||
{ | ||
_mappings = mappings; | ||
} | ||
|
||
public void BuildMappingBodies() | ||
{ | ||
foreach (var (typeMapping, ctx) in _mappings.DequeueMappingsToBuildBody()) | ||
{ | ||
switch (typeMapping) | ||
{ | ||
case NewInstanceObjectPropertyMapping mapping: | ||
NewInstanceObjectPropertyMappingBodyBuilder.BuildMappingBody(ctx, mapping); | ||
break; | ||
case IPropertyAssignmentTypeMapping mapping: | ||
ObjectPropertyMappingBodyBuilder.BuildMappingBody(ctx, mapping); | ||
break; | ||
case UserDefinedNewInstanceMethodMapping mapping: | ||
UserMethodMappingBodyBuilder.BuildMappingBody(ctx, mapping); | ||
break; | ||
case UserDefinedExistingTargetMethodMapping mapping: | ||
UserMethodMappingBodyBuilder.BuildMappingBody(ctx, mapping); | ||
break; | ||
} | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...stanceObjectPropertyMappingBodyBuilder.cs → ...stanceObjectPropertyMappingBodyBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.