public DefaultMemberMapper(MappingContainer container, MemberMapOptions options, MappingMember targetMember, MappingMember sourceMember, ValueConverter converter) : base(container, options, targetMember, converter) { if (sourceMember == null) { throw new ArgumentNullException(nameof(sourceMember)); } _sourceMember = sourceMember; }
/// <summary> /// Specify the member mapping strategy with the source and target members. /// </summary> /// <param name="sourceMember">The source mapping member.</param> /// <param name="targetMember">The target mapping member.</param> /// <returns>The member mapping strategy.</returns> public MemberMapping Set(MappingMember sourceMember, MappingMember targetMember) { var mapping = _mappings.FirstOrDefault(m => m.TargetMember == targetMember); if (mapping == null) { _mappings.Add(mapping = new MemberMapping(sourceMember, targetMember)); } else { mapping.SourceMember = sourceMember; } return(mapping); }
public void Set <TSource, TMember>(MappingMember targetMember, Func <TSource, TMember> expression) { CheckReadOnly(); if (targetMember == null) { throw new ArgumentNullException(nameof(targetMember)); } if (expression == null) { throw new ArgumentNullException(nameof(expression)); } Remove(targetMember); _mappers.Add(new LambdaMemberMapper <TSource, TMember>(_container, _options, targetMember, expression)); }
public void Set(MappingMember targetMember, MappingMember sourceMember, ValueConverter converter = null) { CheckReadOnly(); if (targetMember == null) { throw new ArgumentNullException(nameof(targetMember)); } if (sourceMember == null) { throw new ArgumentNullException(nameof(sourceMember)); } Remove(targetMember); _mappers.Add(new DefaultMemberMapper(_container, _options, targetMember, sourceMember, converter)); }
public LambdaMemberMapper(MappingContainer container, MemberMapOptions options, MappingMember targetMember, Func <TSource, TMember> expression) : base(container, options, targetMember, null) { if (expression == null) { throw new ArgumentNullException(nameof(expression)); } _expression = expression; }
/// <summary> /// Ignore the specified member during mapping. /// </summary> /// <param name="targetMember">The target member to ignore during mapping.</param> public void Ignore(MappingMember targetMember) { _mappings.RemoveAll(mapping => mapping.TargetMember == targetMember); }
internal MemberMapping(MappingMember sourceMember, MappingMember targetMember) { SourceMember = sourceMember; TargetMember = targetMember; }
public MemberMapper this[MappingMember targetMember] => Get(targetMember);