Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public static bool CanMapProperties(MappingProperties propertiesMapping)
 {
     return(AssigmentHelper.CanAssign(propertiesMapping) && propertiesMapping.Destination.CanWrite);
 }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
 internal static bool CanAssign(MappingProperties propertiesMapping)
 {
     return(CanAssign(propertiesMapping.Source.PropertyType, propertiesMapping.Destination.PropertyType));
 }