public virtual void Compile(ModuleBuilder builder) { var sourceType = SourceType; var targetType = TargetMember.MemberType; if (_converter == null) { _converter = _container.Converters.Get(sourceType, targetType); } if (_converter == null) { _converter = CreateConverter(sourceType, targetType); } _converter?.Compile(builder); if (_mapper == null) { _mapper = CreateMapper(sourceType, targetType); } _mapper?.Compile(builder); if ((_converter == null || _mapper == null) && HasOption(MemberMapOptions.Hierarchy) && !( #if NetCore TargetMember.MemberType.GetTypeInfo().IsValueType #else TargetMember.MemberType.IsValueType #endif && targetType == sourceType)) { EnsureMapperType(sourceType, targetType, builder); } }
public static bool TryCreate(Type sourceType, Type targetType, MappingContainer container, out ValueMapper mapper) { mapper = null; Type sourceElementType, targetElementType; if (sourceType.IsEnumerable(out sourceElementType) && targetType.IsEnumerable(out targetElementType)) { #if NETSTANDARD var sourceElementTypeInfo = sourceElementType.GetTypeInfo(); var targetElementTypeInfo = targetElementType.GetTypeInfo(); #else var sourceElementTypeInfo = sourceElementType; var targetElementTypeInfo = targetElementType; #endif if (!sourceElementTypeInfo.IsValueType && !sourceElementTypeInfo.IsPrimitive && !targetElementTypeInfo.IsValueType && !targetElementTypeInfo.IsPrimitive) { mapper = new EnumerableMapper(container, sourceElementType, targetElementType); return(true); } } return(false); }