Exemplo n.º 1
0
 public MappingMemberPath(List <MemberInfo> source, List <MemberInfo> target, TypePair typePair)
 {
     Source         = source;
     OneLevelSource = source.Count == 1;
     OneLevelTarget = target.Count == 1;
     Target         = target;
     TypePair       = typePair;
     Tail           = new MappingMember(source[source.Count - 1], target[target.Count - 1], typePair);
     Head           = new MappingMember(source[0], target[0], new TypePair(source[0].GetMemberType(), target[0].GetMemberType()));
 }
Exemplo n.º 2
0
        private static IEmitterType StoreTargetObjectMember(MappingMember member, IEmitterType targetObject, IEmitterType convertedMember)
        {
            IEmitterType result = null;

            member.Target
            .ToOption()
            .Match(x => x.IsField(), x => result    = StoreFiled((FieldInfo)x, targetObject, convertedMember))
            .Match(x => x.IsProperty(), x => result = StoreProperty((PropertyInfo)x, targetObject, convertedMember));
            return(result);
        }
Exemplo n.º 3
0
        private IEmitterType ConvertMember(TypePair parentTypePair, MappingMember member, IEmitterType sourceMemeber, IEmitterType targetMember)
        {
            //            if (member.TypePair.IsDeepCloneable && _config.GetBindingConfig(parentTypePair).HasNoValue)
            if (member.TypePair.IsDeepCloneable)
            {
                return(sourceMemeber);
            }

            var mapperCacheItem = CreateMapperCacheItem(parentTypePair, member);

            var result = mapperCacheItem.EmitMapMethod(sourceMemeber, targetMember);

            return(result);
        }
Exemplo n.º 4
0
        private MapperCacheItem CreateMapperCacheItem(TypePair parentTypePair, MappingMember mappingMember)
        {
            var mapperCacheItemOption = _mapperCache.Get(mappingMember.TypePair);

            if (mapperCacheItemOption.HasValue)
            {
                return(mapperCacheItemOption.Value);
            }

            var mapperBuilder   = _config.GetMapperBuilder(parentTypePair, mappingMember);
            var mapper          = mapperBuilder.Build(parentTypePair, mappingMember);
            var mapperCacheItem = _mapperCache.Add(mappingMember.TypePair, mapper);

            return(mapperCacheItem);
        }