private void LoadDomainModel(Type type) { if (IsModelLoaded(type)) { return; } DomainModel domainModel; DomainObjectIdAttribute attr = GetAttribute <DomainObjectIdAttribute>(type, false); if (attr == null) { return; } domainModel = this.FindDomainModel(attr.Id) as DomainModel; if (!(domainModel is DomainModelBase)) { domainModelsNotRequired.Add(type); return; } if (domainModel == null) { object[] objArr = new object[] { this }; domainModel = (DomainModelBase)System.Activator.CreateInstance(type, objArr); } this.domainDataAdvDirectory.ProcessClassInfos((domainModel as DomainModelBase).GetDomainClassAdvancedInfo()); this.domainDataAdvDirectory.ProcessRelationshipInfos((domainModel as DomainModelBase).GetDomainRelationshipAdvancedInfo()); this.domainDataAdvDirectory.ProcessEmbeddingRelationshipOrderInfo((domainModel as DomainModelBase).GetEmbeddingRelationshipOrderInfo()); this.domainDataAdvDirectory.ProcessModelContextInfos((domainModel as DomainModelBase).GetModelContextInfo()); this.domainDataAdvDirectory.ProcessDataExtensions((domainModel as DomainModelBase).GetDataExtensions()); this.domainModelsLoaded.Add(type); }
/// <summary> /// Gets the domain property id of a property on a model element. /// </summary> /// <param name="modelElement">Model element containing the named property.</param> /// <param name="propertyName">Property name of the property, for which to get the property domain id.</param> /// <returns>Domain property id if found, null otherwise.</returns> public static Guid?GetPropertyDomainObjectId(ModelElement modelElement, string propertyName) { PropertyInfo propertyInfo = modelElement.GetType().GetProperty(propertyName); if (propertyInfo != null) { object[] obj = propertyInfo.GetCustomAttributes(typeof(DomainObjectIdAttribute), false); if (obj.Length == 1) { DomainObjectIdAttribute idAttribute = (DomainObjectIdAttribute)obj[0]; return(idAttribute.Id); } } return(null); }
void IDeserializationFixupListener.PhaseCompleted(int phase, Store store) { if (phase == myPhase) { foreach (ORMModel model in store.ElementDirectory.FindElements <ORMModel>()) { int knownTypesCount = (int)PortableDataType.UserDefined; DataType[] knownTypes = new DataType[knownTypesCount]; LinkedElementCollection <DataType> currentDataTypes = model.DataTypeCollection; int startingCount = currentDataTypes.Count; for (int i = 0; i < startingCount; ++i) { DataType existingType = currentDataTypes[i]; int currentIndex = (int)existingType.PortableDataType; if (currentIndex >= 0 && currentIndex < knownTypesCount) { Debug.Assert(knownTypes[currentIndex] == null); knownTypes[currentIndex] = existingType; } } ElementFactory factory = store.ElementFactory; for (int i = 0; i < knownTypesCount; ++i) { if (null == knownTypes[i]) { Type newType = null; if (i < typeArray.Length) { newType = typeArray[i]; } Debug.Assert(newType != null); DomainObjectIdAttribute newTypeDomainObjectIdAttribute = (DomainObjectIdAttribute)newType.GetCustomAttributes(typeof(DomainObjectIdAttribute), false)[0]; DataType newDataType = (DataType)factory.CreateElement(newTypeDomainObjectIdAttribute.Id); newDataType.Model = model; knownTypes[i] = newDataType; } } // Cache these for later use model.myPortableTypes = knownTypes; } } }