AutoMapper.Execution.TypeMapPlanBuilder.CreateAssignmentFunc C# (CSharp) Method

CreateAssignmentFunc() private method

private CreateAssignmentFunc ( Expression destinationFunc, bool constructorMapping ) : Expression
destinationFunc System.Linq.Expressions.Expression
constructorMapping bool
return System.Linq.Expressions.Expression
        private Expression CreateAssignmentFunc(Expression destinationFunc, bool constructorMapping)
        {
            var actions = new List<Expression>();
            foreach(var propertyMap in _typeMap.GetPropertyMaps())
            {
                if(!propertyMap.CanResolveValue())
                {
                    continue;
                }
                var property = TryPropertyMap(propertyMap);
                if(constructorMapping && _typeMap.ConstructorParameterMatches(propertyMap.DestinationProperty.Name))
                {
                    property = IfThen(NotEqual(_initialDestination, Constant(null)), property);
                }
                actions.Add(property);
            }
            foreach(var beforeMapAction in _typeMap.BeforeMapActions)
            {
                actions.Insert(0, beforeMapAction.ReplaceParameters(_source, _destination, _context));
            }
            actions.Insert(0, destinationFunc);
            if(_typeMap.MaxDepth > 0)
            {
                actions.Insert(0, Call(_context, ((MethodCallExpression)IncTypeDepthInfo.Body).Method, Constant(_typeMap.Types)));
            }
            actions.AddRange(
                _typeMap.AfterMapActions.Select(
                    afterMapAction => afterMapAction.ReplaceParameters(_source, _destination, _context)));

            if(_typeMap.MaxDepth > 0)
            {
                actions.Add(Call(_context, ((MethodCallExpression)DecTypeDepthInfo.Body).Method, Constant(_typeMap.Types)));
            }

            actions.Add(_destination);

            return Block(actions);
        }