protected virtual ValueConverter CreateConverter(Type sourceType, Type targetType) { if (HasOption(MemberMapOptions.Hierarchy)) { if (EnumerableValueConverter.TryCreate(sourceType, targetType, _container, out var converter)) { return(converter); } } return(null); }
internal Func <TSource, TTarget> GetMapFunc <TSource, TTarget>() { Compile(); var converter = Converters.Get <TSource, TTarget>(); if (converter != null) { return((Func <TSource, TTarget>)converter.CreateDelegate(typeof(TSource), typeof(TTarget), _moduleBuilder)); } if (EnumerableValueConverter.TryCreate(typeof(TSource), typeof(TTarget), this, out converter)) { converter.Compile(_moduleBuilder); return((Func <TSource, TTarget>)converter.CreateDelegate(typeof(TSource), typeof(TTarget), _moduleBuilder)); } var typeMapper = TypeMapper <TSource, TTarget> .GetInstance(this); typeMapper.SetReadOnly(); typeMapper.Compile(_moduleBuilder); return(typeMapper.CreateConverter(_moduleBuilder)); }