-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from AutoMapper/SupportIncludeMembers
Supporting IncludeMembers.
- Loading branch information
Showing
8 changed files
with
572 additions
and
26 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
41 changes: 41 additions & 0 deletions
41
src/AutoMapper.Extensions.ExpressionMapping/Structures/DeclaringMemberKey.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,41 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace AutoMapper.Extensions.ExpressionMapping.Structures | ||
{ | ||
internal class DeclaringMemberKey : IEquatable<DeclaringMemberKey> | ||
{ | ||
public DeclaringMemberKey(MemberInfo declaringMemberInfo, string declaringMemberFullName) | ||
{ | ||
DeclaringMemberInfo = declaringMemberInfo; | ||
DeclaringMemberFullName = declaringMemberFullName; | ||
} | ||
|
||
public MemberInfo DeclaringMemberInfo { get; set; } | ||
public string DeclaringMemberFullName { get; set; } | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) return false; | ||
if (ReferenceEquals(this, obj)) return true; | ||
|
||
DeclaringMemberKey key = obj as DeclaringMemberKey; | ||
if (key == null) return false; | ||
|
||
return Equals(key); | ||
} | ||
|
||
public bool Equals(DeclaringMemberKey other) | ||
{ | ||
if (ReferenceEquals(null, other)) return false; | ||
if (ReferenceEquals(this, other)) return true; | ||
|
||
return this.DeclaringMemberInfo.Equals(other.DeclaringMemberInfo) | ||
&& this.DeclaringMemberFullName == other.DeclaringMemberFullName; | ||
} | ||
|
||
public override int GetHashCode() => this.DeclaringMemberInfo.GetHashCode(); | ||
|
||
public override string ToString() => this.DeclaringMemberFullName; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/AutoMapper.Extensions.ExpressionMapping/Structures/MemberAssignmentInfo.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,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq.Expressions; | ||
using System.Text; | ||
|
||
namespace AutoMapper.Extensions.ExpressionMapping.Structures | ||
{ | ||
internal class MemberAssignmentInfo | ||
{ | ||
public MemberAssignmentInfo(PropertyMap propertyMap, MemberAssignment memberAssignment) | ||
{ | ||
PropertyMap = propertyMap; | ||
MemberAssignment = memberAssignment; | ||
} | ||
|
||
/// <summary> | ||
/// Used to get the source member to be bound with the mapped binding expression. | ||
/// </summary> | ||
public PropertyMap PropertyMap { get; set; } | ||
|
||
/// <summary> | ||
/// Initial member assignment who's binding expression will be mapped and assigned to the source menber of the new type | ||
/// </summary> | ||
public MemberAssignment MemberAssignment { get; set; } | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/AutoMapper.Extensions.ExpressionMapping/Structures/MemberBindingGroup.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,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace AutoMapper.Extensions.ExpressionMapping.Structures | ||
{ | ||
/// <summary> | ||
/// Defines the type to be initialized and a list of source bindings. | ||
/// The new bound members will be matched using MemberAssignmentInfos.PropertyMap and | ||
/// assigned to the mapped expression (mapped from MemberAssignmentInfos.MemberAssignment.Expression). | ||
/// </summary> | ||
internal class MemberBindingGroup | ||
{ | ||
public MemberBindingGroup(DeclaringMemberKey declaringMemberKey, bool isRootMemberAssignment, Type newType, List<MemberAssignmentInfo> memberAssignmentInfos) | ||
{ | ||
DeclaringMemberKey = declaringMemberKey; | ||
IsRootMemberAssignment = isRootMemberAssignment; | ||
NewType = newType; | ||
MemberAssignmentInfos = memberAssignmentInfos; | ||
} | ||
|
||
/// <summary> | ||
/// DeclaringMemberKey will be null when the member assignment is a member binding of OldType on the initial (root) TypeMap (OldType -> NewType) | ||
/// </summary> | ||
public DeclaringMemberKey DeclaringMemberKey { get; set; } | ||
|
||
/// <summary> | ||
/// MemberAssignment is true if it is a member binding of OldType on the initial (root) TypeMap (OldType -> NewType) | ||
/// </summary> | ||
public bool IsRootMemberAssignment { get; set; } | ||
|
||
/// <summary> | ||
/// Destination type of the member assignment. If IsRootMemberAssignment == true then this is the destination type of initial (root) TypeMap (OldType -> NewType) | ||
/// Otherwise it is the PropertyType/FieldType of DeclaringMemberInfo | ||
/// </summary> | ||
public Type NewType { get; set; } | ||
|
||
/// <summary> | ||
/// List of members to be mapped and bound to the new type | ||
/// </summary> | ||
public List<MemberAssignmentInfo> MemberAssignmentInfos { get; set; } | ||
} | ||
} |
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.