public LambdaExpression CreateMapperLambda()
{
if(_typeMap.SourceType.IsGenericTypeDefinition() || _typeMap.DestinationTypeToUse.IsGenericTypeDefinition())
{
return null;
}
var customExpression = TypeConverterMapper() ?? _typeMap.Substitution ?? _typeMap.CustomMapper ?? _typeMap.CustomProjection;
if(customExpression != null)
{
return Lambda(customExpression.ReplaceParameters(_source, _initialDestination, _context), _source, _initialDestination, _context);
}
bool constructorMapping;
var destinationFunc = CreateDestinationFunc(out constructorMapping);
var assignmentFunc = CreateAssignmentFunc(destinationFunc, constructorMapping);
var mapperFunc = CreateMapperFunc(assignmentFunc);
var checkContext = CheckContext(_typeMap, _context);
var lambaBody = (checkContext != null) ? new[] { checkContext, mapperFunc } : new[] { mapperFunc };
return Lambda(Block(new[] { _destination }, lambaBody), _source, _initialDestination, _context);
}