public virtual void PerformModelBuild(IModel model) { ModelElementTypeImpl referenceTargetType = (ModelElementTypeImpl)model.GetType(typeof(TTarget)); ModelElementTypeImpl referenceSourceType = (ModelElementTypeImpl)model.GetType(typeof(TSource)); ElementReferenceCollectionImpl.ReferenceTargetElementType = referenceTargetType; ElementReferenceCollectionImpl.SetReferenceSourceElementType(referenceSourceType); // the referenced attribute may be declared on a base type of the referenced type. AttributeImpl idAttribute = (AttributeImpl)referenceTargetType.GetAttribute("id"); if (idAttribute != null) { idAttribute.RegisterIncoming(ElementReferenceCollectionImpl); ElementReferenceCollectionImpl.ReferenceTargetAttribute = idAttribute; } else { throw new ModelException("Unable to find id attribute of " + typeof(TTarget)); } }
public virtual void PerformModelBuild(IModel model) { // register declaring type as a referencing type of referenced type var referenceTargetType = (ModelElementTypeImpl)model.GetType(typeof(T)); // the actual referenced type _attributeReferenceCollection.ReferenceTargetElementType = referenceTargetType; // the referenced attribute may be declared on a base type of the referenced type. AttributeImpl idAttribute = (AttributeImpl)referenceTargetType.GetAttribute("id"); if (idAttribute != null) { idAttribute.RegisterIncoming(_attributeReferenceCollection); _attributeReferenceCollection.ReferenceTargetAttribute = idAttribute; } else { throw new ModelException("XmlElement type " + referenceTargetType.TypeNamespace + ":" + referenceTargetType.TypeName + " has no id attribute"); } }