public static Expression GetValueConversionOrCreation( this IMemberMapperData mapperData, Expression value, Type targetType) { if (!mapperData.HasConfiguredSimpleTypeValueFactories()) { return(mapperData.GetValueConversion(value, targetType)); } var valueFactories = mapperData .QuerySimpleTypeValueFactories(value.Type, targetType) .ToArray(); if (valueFactories.None()) { return(mapperData.GetValueConversion(value, targetType)); } return(mapperData.GetConversionOrCreationExpression(value, targetType, valueFactories)); }
public static bool CanConvert(this IMemberMapperData mapperData, Type sourceType, Type targetType) { return(mapperData.MapperContext.ValueConverters.CanConvert(sourceType, targetType) || (mapperData.HasConfiguredSimpleTypeValueFactories() && mapperData.QuerySimpleTypeValueFactories(sourceType, targetType).Any())); }