9using System.Collections.Generic;
23 internal class MemberMapping
25 public DynamicMemberHandle FromMemberHandle {
get;
private set; }
26 public DynamicMemberHandle ToMemberHandle {
get;
private set; }
28 public MemberMapping(DynamicMemberHandle fromMemberHandle, DynamicMemberHandle toMemberHandle)
30 FromMemberHandle = fromMemberHandle;
31 ToMemberHandle = toMemberHandle;
37 private Type _sourceType;
38 private Type _targetType;
39 private List<MemberMapping> _map =
new List<MemberMapping>();
50 public DataMap(Type sourceType, Type targetType)
52 _sourceType = sourceType;
53 _targetType = targetType;
66 public DataMap(Type sourceType, Type targetType, IEnumerable<string> includedPropertyNames)
68 foreach (var item
in includedPropertyNames)
72 internal List<MemberMapping> GetMap()
89 _map.Add(
new MemberMapping(
90 MethodCaller.GetCachedProperty(_sourceType, sourceProperty),
91 MethodCaller.GetCachedProperty(_targetType, targetProperty)
106 _map.Add(
new MemberMapping(
107 MethodCaller.GetCachedField(_sourceType, sourceField),
108 MethodCaller.GetCachedField(_targetType, targetField)
123 _map.Add(
new MemberMapping(
124 MethodCaller.GetCachedField(_sourceType, sourceField),
125 MethodCaller.GetCachedProperty(_targetType, targetProperty)
140 _map.Add(
new MemberMapping(
141 MethodCaller.GetCachedProperty(_sourceType, sourceProperty),
142 MethodCaller.GetCachedField(_targetType, targetField)
Defines a mapping between two sets of properties/fields for use by DataMapper.
void AddPropertyToFieldMapping(string sourceProperty, string targetField)
Adds a property to field mapping.
void AddFieldToPropertyMapping(string sourceField, string targetProperty)
Adds a field to property mapping.
DataMap(Type sourceType, Type targetType, IEnumerable< string > includedPropertyNames)
Initializes an instance of the type.
void AddFieldMapping(string sourceField, string targetField)
Adds a field to field mapping.
void AddPropertyMapping(string sourceProperty, string targetProperty)
Adds a property to property mapping.
DataMap(Type sourceType, Type targetType)
Initializes an instance of the type.