protected void HandlePrimitiveCollections(ValueObjectConfig config, IMap <String, IList <XElement> > configDetails) { IList <XElement> memberTags = configDetails.Get(XmlConstants.BASIC.LocalName); if (memberTags == null) { return; } for (int j = memberTags.Count; j-- > 0;) { XElement element = memberTags[j]; String memberName = XmlConfigUtil.GetRequiredAttribute(element, XmlConstants.NAME); if (config.IsIgnoredMember(memberName)) { continue; } config.SetValueObjectMemberType(memberName, ValueObjectMemberType.BASIC); String targetElementTypeName = XmlConfigUtil.GetAttribute(element, XmlConstants.TARGET_ELEMENT_TYPE); if (targetElementTypeName.Length == 0) { continue; } Type elementType = XmlConfigUtil.GetTypeForName(targetElementTypeName); config.PutMemberType(memberName, elementType); } }
protected void HandleRelations(ValueObjectConfig config, IMap <String, IList <XElement> > configDetails) { IList <XElement> elementTypes = configDetails.Get(XmlConstants.RELATION.LocalName); if (elementTypes != null) { for (int i = elementTypes.Count; i-- > 0;) { XElement entry = elementTypes[i]; String memberName = XmlConfigUtil.GetRequiredAttribute(entry, XmlConstants.NAME); if (config.IsIgnoredMember(memberName)) { continue; } config.SetValueObjectMemberType(memberName, ValueObjectMemberType.RELATION); bool holdsListType = XmlConfigUtil.AttributeIsTrue(entry, XmlConstants.LIST_TYPE); if (holdsListType) { config.AddListTypeMember(memberName); } String elementTypeName = XmlConfigUtil.GetAttribute(entry, XmlConstants.TARGET_VALUE_OBJECT); if (elementTypeName.Length > 0) { Type elementType = XmlConfigUtil.GetTypeForName(elementTypeName); config.PutMemberType(memberName, elementType); } } } }
protected void HandleMemberMappings(ValueObjectConfig config, IMap <String, IList <XElement> > configDetails, IEntityMetaData metaData) { Type entityType = config.EntityType; Type valueType = config.ValueType; IMap <String, IPropertyInfo> entityPropertyMap = PropertyInfoProvider.GetPropertyMap(entityType); IMap <String, IPropertyInfo> valuePropertyMap = PropertyInfoProvider.GetPropertyMap(valueType); for (int i = memberTagNames.Length; i-- > 0;) { String memberTagName = memberTagNames[i].LocalName; IList <XElement> memberTags = configDetails.Get(memberTagName); if (memberTags == null) { continue; } for (int j = memberTags.Count; j-- > 0;) { XElement element = memberTags[j]; String memberName = XmlConfigUtil.GetRequiredAttribute(element, XmlConstants.NAME); if (config.IsIgnoredMember(memberName)) { continue; } if (RuntimeValidationActive && !IsPropertyResolvable(valueType, valuePropertyMap, memberName, null)) { throw new ArgumentException("Value type property '" + valueType.Name + "." + memberName + "' not found"); } bool holdsListType = XmlConfigUtil.AttributeIsTrue(element, XmlConstants.LIST_TYPE); if (holdsListType) { config.AddListTypeMember(memberName); } String entityMemberName = XmlConfigUtil.GetAttribute(element, XmlConstants.NAME_IN_ENTITY); if (entityMemberName.Length == 0) { entityMemberName = memberName; } else { config.PutValueObjectMemberName(entityMemberName, memberName); } if (RuntimeValidationActive && !IsPropertyResolvable(entityType, entityPropertyMap, entityMemberName, metaData)) { throw new ArgumentException("Entity type property '" + entityType.Name + "." + entityMemberName + "' not found while configuring value type '" + valueType.Name + "'"); } } } }