-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Leonardo Porro
committed
Jan 29, 2024
1 parent
291ed2a
commit 455c689
Showing
22 changed files
with
133 additions
and
57 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
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
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
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
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
12 changes: 12 additions & 0 deletions
12
src/Detached.Mappers/TypePairs/Conventions/CamelCaseMemberNameConvention.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,12 @@ | ||
using Detached.Mappers.Types; | ||
|
||
namespace Detached.Mappers.TypePairs.Conventions | ||
{ | ||
public class CamelCaseMemberNameConvention : IMemberNameConvention | ||
{ | ||
public string GetSourceMemberName(string targetMemberName, IType sourceType, IType targetType, MapperOptions mapperOptions) | ||
{ | ||
return char.ToLower(targetMemberName[0]) + targetMemberName.Substring(1); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Detached.Mappers/TypePairs/Conventions/DefaultMemberNameConvention.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,12 @@ | ||
using Detached.Mappers.Types; | ||
|
||
namespace Detached.Mappers.TypePairs.Conventions | ||
{ | ||
public class DefaultMemberNameConvention : IMemberNameConvention | ||
{ | ||
public string GetSourceMemberName(string targetMemberName, IType sourceType, IType targetType, MapperOptions mapperOptions) | ||
{ | ||
return targetMemberName; | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Detached.Mappers/TypePairs/Conventions/ForeignKeyMemberNameConvention.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,35 @@ | ||
using Detached.Mappers.Types; | ||
using Humanizer; | ||
|
||
namespace Detached.Mappers.TypePairs.Conventions | ||
{ | ||
public class ForeignKeyMemberNameConvention : IMemberNameConvention | ||
{ | ||
public string GetSourceMemberName(string targetMemberName, IType sourceType, IType targetType, MapperOptions mapperOptions) | ||
{ | ||
string memberName = null; | ||
|
||
if (targetType.IsEntity()) | ||
{ | ||
var key = targetType.GetKeyMember(); | ||
|
||
if (key != null) | ||
{ | ||
var member = targetType.GetMember(targetMemberName); | ||
var memberType = mapperOptions.GetType(member.ClrType); | ||
|
||
if (memberType.IsCollection()) | ||
{ | ||
memberName = targetMemberName.Singularize(false) + key.Name.Pluralize(false); | ||
} | ||
else | ||
{ | ||
memberName = targetMemberName + key.Name; | ||
} | ||
} | ||
} | ||
|
||
return memberName; | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Detached.Mappers/TypePairs/Conventions/IMemberNameConvention.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,9 @@ | ||
using Detached.Mappers.Types; | ||
|
||
namespace Detached.Mappers.TypePairs.Conventions | ||
{ | ||
public interface IMemberNameConvention | ||
{ | ||
string GetSourceMemberName(string targetMemberName, IType sourceType, IType targetType, MapperOptions mapperOptions); | ||
} | ||
} |
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
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
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
10 changes: 0 additions & 10 deletions
10
src/Detached.Mappers/Types/Conventions/CamelCasePropertyNameConvention.cs
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
src/Detached.Mappers/Types/Conventions/IPropertyNameConvention.cs
This file was deleted.
Oops, something went wrong.
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