public MapperBuilder GetMapperBuilder(TypePair parentTypePair, MappingMember mappingMember)
 {
     if (_customTypeMapperBuilder.IsSupported(parentTypePair, mappingMember))
     {
         return _customTypeMapperBuilder;
     }
     return GetTypeMapperBuilder(mappingMember.TypePair);
 }
예제 #2
0
        private MapperCacheItem CreateMapperCacheItem(TypePair parentTypePair, MappingMember mappingMember)
        {
            MapperBuilder mapperBuilder = _config.GetMapperBuilder(parentTypePair, mappingMember);
            Mapper mapper = mapperBuilder.Build(parentTypePair, mappingMember);
            MapperCacheItem mapperCacheItem = _mapperCache.Add(mappingMember.TypePair, mapper);

            return mapperCacheItem;
        }
예제 #3
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;
 }
 public bool IsSupported(TypePair parentTypePair, MappingMember mappingMember)
 {
     Option<BindingConfig> bindingConfig = _config.GetBindingConfig(parentTypePair);
     if (bindingConfig.HasNoValue)
     {
         return false;
     }
     return bindingConfig.Value.HasCustomTypeConverter(mappingMember.Target.Name);
 }
예제 #5
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);
        }
예제 #6
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()));
 }
예제 #7
0
        private IEmitterType ConvertMember(MappingMember member, IEmitterType sourceMemeber, IEmitterType targetMember)
        {
            if (member.TypePair.IsDeepCloneable)
            {
                return sourceMemeber;
            }

            MapperCacheItem mapperCacheItem = CreateMapperCacheItem(member.TypePair);

            IEmitterType result = mapperCacheItem.EmitMapMethod(sourceMemeber, targetMember);
            return result;
        }
예제 #8
0
        private IEmitterType ConvertMember(TypePair parentTypePair, MappingMember member, IEmitterType sourceMemeber, IEmitterType targetMember)
        {
            if (member.TypePair.IsDeepCloneable && _config.GetBindingConfig(parentTypePair).HasNoValue)
            {
                return sourceMemeber;
            }

            MapperCacheItem mapperCacheItem = CreateMapperCacheItem(parentTypePair, member);

            IEmitterType result = mapperCacheItem.EmitMapMethod(sourceMemeber, targetMember);
            return result;
        }
예제 #9
0
        private IEmitter Build(MappingMember member)
        {
            IEmitterType sourceObject = EmitArgument.Load(member.Source.GetMemberType(), 1);
            IEmitterType targetObject = EmitArgument.Load(member.Target.GetMemberType(), 2);

            IEmitterType sourceMember = LoadMember(member.Source, sourceObject);
            IEmitterType targetMember = LoadMember(member.Target, targetObject);

            IEmitterType convertedMember = ConvertMember(member, sourceMember, targetMember);

            IEmitter result = StoreTargetObjectMember(member, targetObject, convertedMember);
            return result;
        }
예제 #10
0
        private IEmitterType ConvertMember(MappingMember member, IEmitterType sourceMemeber, IEmitterType targetMember)
        {
            if (member.TypePair.IsDeepCloneable)
            {
                return(sourceMemeber);
            }

            MapperCacheItem mapperCacheItem = CreateMapperCacheItem(member.TypePair);

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

            return(result);
        }
예제 #11
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);
            }

            MapperCacheItem mapperCacheItem = CreateMapperCacheItem(parentTypePair, member);

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

            return(result);
        }
예제 #12
0
        private IEmitter Build(MappingMember member)
        {
            IEmitterType sourceObject = EmitArgument.Load(member.TypePair.Source, 1);
            IEmitterType targetObject = EmitArgument.Load(member.TypePair.Target, 2);

            IEmitterType sourceMember = LoadMember(member.Source, sourceObject);
            IEmitterType targetMember = LoadMember(member.Target, targetObject);

            IEmitterType convertedMember = ConvertMember(member, sourceMember, targetMember);

            IEmitter result = StoreTargetObjectMember(member, targetObject, convertedMember);

            return(result);
        }
예제 #13
0
        private MapperCacheItem CreateMapperCacheItem(TypePair parentTypePair, MappingMember mappingMember)
        {
            var mapperCacheItemOption = _mapperCache.Get(mappingMember.TypePair);

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

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

            return(mapperCacheItem);
        }
예제 #14
0
 public Mapper Build(TypePair parentTypePair, MappingMember mappingMember)
 {
     return BuildCore(parentTypePair, mappingMember);
 }
 protected override Mapper BuildCore(TypePair parentTypePair, MappingMember mappingMember)
 {
     Option<BindingConfig> bindingConfig = _config.GetBindingConfig(parentTypePair);
     Func<object, object> converter = bindingConfig.Value.GetCustomTypeConverter(mappingMember.Target.Name).Value;
     return new CustomTypeMapper(converter);
 }
예제 #16
0
 protected abstract Mapper BuildCore(TypePair parentTypePair, MappingMember mappingMember);
 protected override Mapper BuildCore(TypePair parentTypePair, MappingMember mappingMember)
 {
     return BuildCore(mappingMember.TypePair);
 }
 public MapperBuilder GetMapperBuilder(TypePair parentTypePair, MappingMember mappingMember)
 {
     throw new NotImplementedException();
 }