Beispiel #1
0
        protected virtual Expression GetKeyOrValueExpression(DictionaryMapperContext context,
                                                             ParameterExpression sourceParam, ParameterExpression targetParam)
        {
            if (sourceParam.Type.IsBuiltInType(false) &&
                targetParam.Type.IsBuiltInType(false))
            {
                var itemMapping = MapperConfiguration[sourceParam.Type,
                                                      targetParam.Type].MappingExpression;

                var itemMappingExp = itemMapping.Body.ReplaceParameter(
                    sourceParam, itemMapping.Parameters[0].Name);

                return(Expression.Assign(targetParam, itemMappingExp));
            }

            return(base.LookUpBlock(context, sourceParam, targetParam));
        }
Beispiel #2
0
        protected virtual Expression GetKeyOrValueExpression(DictionaryMapperContext context,
                                                             ParameterExpression sourceParam, ParameterExpression targetParam)
        {
            if ((sourceParam.Type.IsBuiltIn(false) && targetParam.Type.IsBuiltIn(false)) ||
                (!sourceParam.Type.IsClass || !targetParam.Type.IsClass))
            {
                var itemMapping = MapperConfiguration[sourceParam.Type,
                                                      targetParam.Type].MappingExpression;

                var itemMappingExp = itemMapping.Body.ReplaceParameter(
                    sourceParam, "sourceInstance");

                return(Expression.Assign(targetParam, itemMappingExp));
            }

            return(base.LookUpBlock(sourceParam, targetParam,
                                    context.ReferenceTracker, context.Mapper));
        }