示例#1
0
        public Expression MapExpression(IConfigurationProvider configurationProvider, ProfileMap profileMap,
                                        PropertyMap propertyMap, Expression sourceExpression, Expression destExpression,
                                        Expression contextExpression)
        {
            MethodCallExpression result = Call(null,
                                               MapMethodInfo.MakeGenericMethod(sourceExpression.Type, destExpression.Type),
                                               sourceExpression,
                                               ToType(
                                                   Coalesce(ToObject(destExpression),
                                                            DelegateFactory.GenerateConstructorExpression(destExpression.Type)), destExpression.Type),
                                               contextExpression,
                                               Constant(profileMap));

            DebugHelpers.LogExpression(result, "ToDynamic MapExpression");

            return(result);
        }
示例#2
0
        private BlockExpression CreatePropertyMapFunc(PropertyMap propertyMap, Expression destination)
        {
            Expression       getter;
            MemberExpression destMember          = null;
            MemberInfo       destExtraMemberInfo = null;
            Type             sourceType          = propertyMap.SourceType;

            bool destIsExtra = IsExtraFieldOrProperty(propertyMap.DestinationProperty);

            if (destIsExtra)
            {
                // Retreive the Property or Field Info from the ProfileMap for this extra member.
                destExtraMemberInfo = propertyMap.ExtraDestinationMember;
                getter = CreateGetterExpression(destExtraMemberInfo, destination, propertyMap.SourceType, propertyMap);
            }
            else
            {
                destMember = MakeMemberAccess(destination, propertyMap.DestinationProperty);
                DebugHelpers.LogExpression(destMember, "destMember");

                if (propertyMap.DestinationProperty is PropertyInfo pi && pi.GetGetMethod(true) == null)
                {
                    getter = Default(propertyMap.DestinationPropertyType);
                }