Exemple #1
0
        private static Expression GetDictionaryAssignment(Expression value, IObjectMappingData mappingData)
        {
            var mapperData = mappingData.MapperData;

            if (mapperData.TargetMember.IsReadOnly)
            {
                return(null);
            }

            var valueResolution = TargetObjectResolutionFactory.GetObjectResolution(
                value,
                mappingData,
                mapperData.HasRepeatedMapperFuncs);

            if (valueResolution == mapperData.TargetInstance)
            {
                return(null);
            }

            return(mapperData.TargetInstance.AssignTo(valueResolution));
        }
Exemple #2
0
        public static Expression GetMappingOrNull(
            MappingCreationContext context,
            out bool isConditional)
        {
            var mappingData = context.MappingData;
            var mapping     = GetMappingOrNull(mappingData, out isConditional);

            if ((mapping?.NodeType != ExpressionType.Goto) ||
                (context.PostMappingCallback == null))
            {
                return(mapping);
            }

            mapping = ((GotoExpression)mapping).Value;

            mapping = TargetObjectResolutionFactory.GetObjectResolution(
                mapping,
                mappingData,
                assignTargetObject: true);

            mapping = mappingData.MapperData.LocalVariable.AssignTo(mapping);

            return(mapping);
        }