private void AddCongiguration(MappingTypes typesMapping, MappingProperties propertiesMapping) { List <MappingProperties> registeredMappings; if (!_configuratedMappings.TryGetValue(typesMapping, out registeredMappings)) { registeredMappings = new List <MappingProperties>(); _configuratedMappings[typesMapping] = registeredMappings; } registeredMappings.Add(propertiesMapping); }
public MapperConfiguration Register <TSource, TDestination>( Expression <Func <TSource, object> > sourcePropertyAccessor, Expression <Func <TDestination, object> > destinationPropertyAccessor) { MappingProperties addingPropertiesMapping = GetAddingsMapping(sourcePropertyAccessor, destinationPropertyAccessor); var typesMapping = new MappingTypes(typeof(TSource), typeof(TDestination)); if (Mapper.CanMapProperties(addingPropertiesMapping)) { AddCongiguration(typesMapping, addingPropertiesMapping); } return(this); }
public static bool CanMapProperties(MappingProperties propertiesMapping) { return(AssigmentHelper.CanAssign(propertiesMapping) && propertiesMapping.Destination.CanWrite); }
private static MemberBinding GetMemberBinding(Expression parameterExpression, MappingProperties mappingProperties) { Expression propertyAccessExpression = Expression.Property(parameterExpression, mappingProperties.Source); Expression convertExpression = Expression.Convert(propertyAccessExpression, mappingProperties.Destination.PropertyType); return(Expression.Bind(mappingProperties.Destination, convertExpression)); }
internal static bool CanAssign(MappingProperties propertiesMapping) { return(CanAssign(propertiesMapping.Source.PropertyType, propertiesMapping.Destination.PropertyType)); }