public Expression MapExpression(IConfigurationProvider configurationProvider, ProfileMap profileMap, PropertyMap propertyMap, Expression sourceExpression, Expression destExpression, Expression contextExpression)
        {
            var listType = typeof(List <>).MakeGenericType(TypeHelper.GetElementType(destExpression.Type));
            var list     = CollectionMapperExtensions.MapCollectionExpression(configurationProvider, profileMap, propertyMap, sourceExpression, Default(listType), contextExpression, _ => Constant(false), typeof(List <>), CollectionMapperExtensions.MapItemExpr);
            var dest     = Variable(listType, "dest");

            return(Block(new[] { dest }, Assign(dest, list), Condition(NotEqual(dest, Default(listType)), New(destExpression.Type.GetConstructors().First(), dest), Default(destExpression.Type))));
        }
Ejemplo n.º 2
0
 public Expression MapExpression(IConfigurationProvider configurationProvider, ProfileMap profileMap, PropertyMap propertyMap, Expression sourceExpression, Expression destExpression, Expression contextExpression)
 {
     if (destExpression.Type.IsInterface())
     {
         var listType = typeof(List <>).MakeGenericType(TypeHelper.GetElementType(destExpression.Type));
         destExpression = Default(listType);
     }
     return(CollectionMapperExtensions.MapCollectionExpression(configurationProvider, profileMap, propertyMap, sourceExpression,
                                                               destExpression, contextExpression, IfEditableList, typeof(List <>), CollectionMapperExtensions.MapItemExpr));
 }
Ejemplo n.º 3
0
 public Expression MapExpression(IConfigurationProvider configurationProvider, ProfileMap profileMap, PropertyMap propertyMap, Expression sourceExpression, Expression destExpression, Expression contextExpression)
 =>
 CollectionMapperExtensions.MapCollectionExpression(configurationProvider, profileMap, propertyMap,
                                                    Call(MembersDictionaryMethodInfo, sourceExpression, Constant(profileMap)), destExpression, contextExpression, _ => null,
                                                    typeof(Dictionary <,>), CollectionMapperExtensions.MapKeyPairValueExpr);
Ejemplo n.º 4
0
 public Expression MapExpression(IConfigurationProvider configurationProvider, ProfileMap profileMap, PropertyMap propertyMap, Expression sourceExpression, Expression destExpression, Expression contextExpression)
 =>
 CollectionMapperExtensions.MapCollectionExpression(configurationProvider, profileMap, propertyMap, sourceExpression, destExpression,
                                                    contextExpression, CollectionMapperExtensions.IfNotNull, typeof(Dictionary <,>), CollectionMapperExtensions.MapItemExpr);