public virtual void IdBag(MemberInfo property, Action <IIdBagPropertiesMapper> collectionMapping, Action <ICollectionElementRelation> mapping) { var hbm = new HbmIdbag { name = property.Name }; System.Type propertyType = property.GetPropertyOrFieldType(); System.Type collectionElementType = propertyType.DetermineCollectionElementType(); collectionMapping(new IdBagMapper(container, collectionElementType, hbm)); mapping(new CollectionElementRelation(collectionElementType, MapDoc, rel => hbm.Item = rel)); AddProperty(hbm); }
public void List(MemberInfo property, Action <IListPropertiesMapper> collectionMapping, Action <ICollectionElementRelation> mapping) { var hbm = new HbmList { name = property.Name }; System.Type propertyType = property.GetPropertyOrFieldType(); System.Type collectionElementType = propertyType.DetermineCollectionElementType(); collectionMapping(new ListMapper(Container, collectionElementType, new NoMemberPropertyMapper(), hbm)); mapping(new CollectionElementRelation(collectionElementType, MapDoc, rel => hbm.Item1 = rel)); AddProperty(hbm); }
public static System.Type DetermineRequiredCollectionElementType(this MemberInfo collectionProperty) { System.Type propertyType = collectionProperty.GetPropertyOrFieldType(); System.Type collectionElementType = propertyType.DetermineCollectionElementType(); if (collectionElementType == null) { var message = string.Format( "Unable to determine collection element type for the property/field '{0}' of {1}. The collection must be generic.", collectionProperty.Name, collectionProperty.DeclaringType != null ? collectionProperty.DeclaringType.FullName : "<global>"); throw new MappingException(message); } return(collectionElementType); }