예제 #1
0
 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;
 }
예제 #2
0
        /// <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);
        }
예제 #3
0
 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));
 }
예제 #4
0
 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));
 }
예제 #5
0
 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;
 }
예제 #6
0
 /// <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);
 }
예제 #7
0
 internal MemberMapping(MappingMember sourceMember, MappingMember targetMember)
 {
     SourceMember = sourceMember;
     TargetMember = targetMember;
 }
예제 #8
0
 public MemberMapper this[MappingMember targetMember] => Get(targetMember);