示例#1
0
        private static Expression GetConvertedValue(Expression value, IMemberMapperData mapperData)
        {
            if (mapperData.TargetMember.IsComplex && !mapperData.TargetMember.Type.IsFromBcl())
            {
                return(value);
            }

            return(mapperData.GetValueConversionOrCreation(value, mapperData.TargetMember.Type));
        }
        public SourceMemberDataSource(
            IQualifiedMember sourceMember,
            Expression sourceMemberValue,
            Expression condition,
            IMemberMapperData mapperData)
            : base(
                sourceMember,
                mapperData.GetValueConversionOrCreation(sourceMemberValue, mapperData.TargetMember.Type),
                mapperData)
        {
            SourceMemberTypeTest = CreateSourceMemberTypeTest(sourceMemberValue, mapperData);

            if (condition == null)
            {
                Condition = base.Condition;
                return;
            }

            Condition = IsConditional ? Expression.AndAlso(base.Condition, condition) : condition;
        }
示例#3
0
        public override Expression GetPopulation(Expression value, IMemberMapperData mapperData)
        {
            if (mapperData.TargetMember.IsRecursion)
            {
                return(value);
            }

            if (this == _rootDictionaryMember)
            {
                return(base.GetPopulation(value, mapperData));
            }

            if (ValueIsFlattening(value, out var flattening))
            {
                return(flattening);
            }

            var keyedAccess     = GetKeyedAccess(mapperData);
            var convertedValue  = mapperData.GetValueConversionOrCreation(value, ValueType);
            var keyedAssignment = keyedAccess.AssignTo(convertedValue);

            return(keyedAssignment);
        }