public MapperBuilder GetMapperBuilder(TypePair parentTypePair, MappingMember mappingMember) { if (_customTypeMapperBuilder.IsSupported(parentTypePair, mappingMember)) { return _customTypeMapperBuilder; } return GetTypeMapperBuilder(mappingMember.TypePair); }
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; }
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); }
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 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())); }
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; }
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; }
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; }
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); }
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); }
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); }
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); }
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); }
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(); }