Beispiel #1
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);
        }
 internal MemberMapping(MappingMember sourceMember, MappingMember targetMember)
 {
     SourceMember = sourceMember;
     TargetMember = targetMember;
 }
Beispiel #3
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);
 }