Example #1
0
        public static void MapValidationException_IfInheritanceMapIsNotForDerivedTypes(TypeMapBase map,
			PropertyMapBase propertyMap, TypeMapBase inheritanceMap)
        {
            Type baseType =
                ReflectionHelper.IsComplexEnumerable(propertyMap.SourcePropertyInfo.PropertyType)
                ? ReflectionHelper.GetEnumerableItemType(propertyMap.SourcePropertyInfo.PropertyType)
                : propertyMap.SourcePropertyInfo.PropertyType;

            Type type =
                (propertyMap.DestinationPropertyInfo != null)
                ? (ReflectionHelper.IsComplexEnumerable(propertyMap.DestinationPropertyInfo.PropertyType)
                    ? ReflectionHelper.GetEnumerableItemType(propertyMap.DestinationPropertyInfo.PropertyType)
                    : propertyMap.DestinationPropertyInfo.PropertyType)
                : null;

            if (!ReflectionHelper.IsAssignable(baseType, inheritanceMap.SourceType)
                || (type != null && !ReflectionHelper.IsAssignable(type, inheritanceMap.DestinationType))
                || (type == null && map.DestinationType != inheritanceMap.DestinationType))
            {
                throw new MapValidationException(string.Format(Resources.InheritanceMapIsNotForDerivedTypes3,
                    (inheritanceMap != null)
                    ? inheritanceMap.ToString()
                    : string.Empty, (propertyMap != null)
                        ? propertyMap.ToString()
                        : string.Empty, (map != null)
                            ? map.ToString()
                            : string.Empty), null);
            }
        }
Example #2
0
 public static void MapValidationException_PropertyMapIsNotSupported(PropertyMapBase map)
 {
     throw new MapValidationException(string.Format(Resources.PropertyMapIsNotSupported1,
         (map != null) ? map.ToString() : string.Empty), null);
 }
Example #3
0
        public static void MapValidationException_IfPropertyMapHasMapperAndInheritanceMapsOrNothing(TypeMapBase typeMap,
			PropertyMapBase propertyMap, Action<object, object, TypeMappingContext> mapper, IEnumerable<TypeMapBase> inheritanceMaps)
        {
            if ((mapper != null && inheritanceMaps != null && inheritanceMaps.Count<TypeMapBase>() > 0)
                || (mapper == null && (inheritanceMaps == null || inheritanceMaps.Count<TypeMapBase>() == 0)))
            {
                throw new MapValidationException(string.Format(Resources.PropertyMapHasMapperAndInheritanceMapsOrNothing2,
                    (propertyMap != null) ? propertyMap.ToString()
                    : string.Empty, (typeMap != null)
                        ? typeMap.ToString()
                        : string.Empty), null);
            }
        }
Example #4
0
        public static void MapValidationException_IfPropertyMapIsNotForBothComplexEnumerableOrComplexTypes(
			TypeMapBase typeMap, PropertyMapBase propertyMap)
        {
            Type propertyType = propertyMap.SourcePropertyInfo.PropertyType;

            Type type = (propertyMap.DestinationPropertyInfo != null) ? propertyMap.DestinationPropertyInfo.PropertyType : null;

            if ((type == null && (ReflectionHelper.IsComplexEnumerable(propertyType)
                || ReflectionHelper.IsSimple(propertyType))) || (type != null && ((ReflectionHelper.IsComplexEnumerable(propertyType) && ReflectionHelper.IsComplex(type)) || (ReflectionHelper.IsComplex(propertyType) && ReflectionHelper.IsComplexEnumerable(type)) || ReflectionHelper.IsSimple(propertyType) || ReflectionHelper.IsSimple(type))))
            {
                throw new MapValidationException(string.Format(Resources.PropertyMapIsNotForBothComplexEnumerableOrComplexTypes2,
                    (propertyMap != null)
                    ? propertyMap.ToString()
                    : string.Empty, (typeMap != null)
                        ? typeMap.ToString()
                        : string.Empty), null);
            }
        }
Example #5
0
        public static void MapValidationException_IfPropertyMapDuplicated(TypeMapBase typeMap, PropertyMapBase propertyMap,
			IEnumerable<PropertyMapBase> propertyMaps)
        {
            if (propertyMaps.Count((PropertyMapBase m) => m.SourcePropertyInfo == propertyMap.SourcePropertyInfo
                || m.DestinationPropertyInfo == propertyMap.DestinationPropertyInfo) > 1)
            {
                throw new MapValidationException(string.Format(Resources.PropertyMapDuplicated2,
                    (propertyMap != null) ? propertyMap.ToString() : string.Empty,
                    (typeMap != null) ? typeMap.ToString() : string.Empty), null);
            }
        }