Ejemplo n.º 1
0
        public ArrayTypeMap(Type srcType, Type destType, Type attrDest)
        {
            var srcElement = ReflectionUtils.GetElementType(srcType);
            var destElement = ReflectionUtils.GetElementType(destType);

            _arrayItemMap = Create(srcElement, destElement, attrDest);
            _destArrayConstructor = ArrayConstructorBase.Create(destType);
        }
Ejemplo n.º 2
0
 public ClassPropertyMap(PropertyInfo srcPropertyInfo, PropertyInfo destPropertyInfo, Type attrType)
 {
     _srcPropertyInfo = srcPropertyInfo;
     _destPropertyInfo = destPropertyInfo;
     _typeMap = TypeMap.Create(srcPropertyInfo.PropertyType, destPropertyInfo.PropertyType, attrType);
 }
Ejemplo n.º 3
0
        public ArrayPropertyMap(PropertyInfo srcPropertyInfo, PropertyInfo destPropertyInfo, Type attrType)
        {

            _srcPropertyInfo = srcPropertyInfo;
            _destPropertyInfo = destPropertyInfo;


            var srcElementType = ReflectionUtils.GetElementType(srcPropertyInfo.PropertyType);
            var destElementType = ReflectionUtils.GetElementType(destPropertyInfo.PropertyType);

            var isSimpleType = ReflectionUtils.IsSimpleType(srcElementType);
            var areInterfaces = IsInterfaces(srcElementType, destElementType);

            if (isSimpleType || areInterfaces)
            {
                // если тип простой, просто проверим чтобы они были одинаковые - иначе ничего может не получиться в рантайме
                if (!areInterfaces && srcElementType != destElementType)
                    throw new Exception("There are different simple element types for mapping Lists. ElementSrc=[" + srcElementType + "]. ElementDest=[" + destElementType + "]. Theyshould be the same");
            }
            else
            {
                _elementTypeMap = TypeMap.Create(srcElementType, destElementType,attrType);
            }

            _destArrayConstructor = ArrayConstructorBase.Create(destPropertyInfo.PropertyType);
        }
Ejemplo n.º 4
0
 public ClassPropertyMap(PropertyInfo srcPropertyInfo, PropertyInfo destPropertyInfo, Type attrType)
 {
     _srcPropertyInfo  = srcPropertyInfo;
     _destPropertyInfo = destPropertyInfo;
     _typeMap          = TypeMap.Create(srcPropertyInfo.PropertyType, destPropertyInfo.PropertyType, attrType);
 }