/// <summary> /// Get all embedded proto elements for the given element. /// </summary> /// <param name="partition">Partition.</param> /// <param name="protoElement">Proto element to get all embedded elements for.</param> /// <returns>List of embedded proto elements.</returns> public List <ModelProtoElement> GetEmbeddedElements(Partition partition, ModelProtoElement protoElement) { List <ModelProtoElement> elements; this.embeddingMapping.TryGetValue(protoElement.ElementId, out elements); return(elements); }
public List <ModelProtoLink> GetReferenceLinksTarget(Partition partition, ModelProtoElement protoElement) { List <ModelProtoLink> elements; this.referencingMappingTarget.TryGetValue(protoElement.ElementId, out elements); return(elements); }
/// <summary> /// Adds a proto element to the proto elements collection. /// </summary> /// <param name="protoElement">Proto element to add to the collection.</param> public void AddNewElement(ModelProtoElement protoElement) { if (!protoElements.Contains(protoElement)) { protoElements.Add(protoElement); } }
/// <summary> /// Adds a proto element to the proto elements collection. /// </summary> /// <param name="protoElement">Proto element to add to the collection.</param> public void AddNewRootElement(ModelProtoElement protoElement) { if (!this.protoRootElements.Contains(protoElement)) { protoRootElements.Add(protoElement); } }
/// <summary> /// Adds a proto element to the proto elements collection. /// </summary> /// <param name="protoElement">Proto element to add to the collection.</param> /// <param name="index">Index.</param> public void InsertNewRootElement(ModelProtoElement protoElement, int index) { if (!this.protoRootElements.Contains(protoElement)) { protoRootElements.Insert(index, protoElement); } }
public override void ModelFinalize(CopyPaste.ModelProtoElement protoElement, CopyPaste.ModelProtoGroupMerger groupMerger) { base.ModelFinalize(protoElement, groupMerger); RootDiagramNode node = new RootDiagramNode(this.Store); node.PresentationElementClass = this; this.DiagramClass.DiagramClassView.RootDiagramNodes.Add(node); }
/// <summary> /// Get all embedded proto elements for the given element. /// </summary> /// <param name="partition">Partition.</param> /// <param name="protoElement">Proto element to get all embedded elements for.</param> /// <returns>List of embedded proto elements.</returns> public List <ModelProtoElement> GetEmbeddedElements(Partition partition, ModelProtoElement protoElement) { if (bNeedsInitialization) { InitDictionaries(partition); } List <ModelProtoElement> elements; this.embeddingMapping.TryGetValue(protoElement.ElementId, out elements); return(elements); }
public List <ModelProtoLink> GetReferenceLinksTarget(Partition partition, ModelProtoElement protoElement) { if (bNeedsInitialization) { InitDictionaries(partition); } List <ModelProtoLink> elements; this.referencingMappingTarget.TryGetValue(protoElement.ElementId, out elements); return(elements); }
public override void ModelFinalize(CopyPaste.ModelProtoElement protoElement, CopyPaste.ModelProtoGroupMerger groupMerger) { base.ModelFinalize(protoElement, groupMerger); if (protoElement.Name == "ReferenceRelationship") { FinalizeReferenceRelationshipMerge(protoElement, groupMerger, true); } else if (protoElement.Name == "EmbeddingRelationship") { FinalizeEmbeddingRelationshipsMerge(protoElement, groupMerger, true); } FinalizeRelationshipMerge(protoElement, groupMerger); }
private void InitDictionaries(Partition partition) { bNeedsInitialization = false; this.embeddingMapping = new Dictionary <Guid, List <ModelProtoElement> >(); this.referencingMapping = new Dictionary <Guid, List <ModelProtoLink> >(); this.referencingMappingTarget = new Dictionary <Guid, List <ModelProtoLink> >(); this.elementMapping = new Dictionary <Guid, ModelProtoElement>(); foreach (ModelProtoElement element in this.ProtoElements) { embeddingMapping.Add(element.ElementId, new List <ModelProtoElement>()); referencingMapping.Add(element.ElementId, new List <ModelProtoLink>()); referencingMappingTarget.Add(element.ElementId, new List <ModelProtoLink>()); elementMapping.Add(element.ElementId, element); } foreach (ModelProtoLink link in this.ProtoEmbeddingLinks) { ModelProtoRolePlayer rolePlayer = link.GetSourceRolePlayer(partition); ModelProtoElement p = GetElementById(rolePlayer.RolePlayerId); if (p != null) { embeddingMapping[p.ElementId].Add( GetElementById(link.GetTargetRolePlayer(partition).RolePlayerId)); } } foreach (ModelProtoLink link in this.ProtoReferenceLinks) { ModelProtoRolePlayer sourceRP = link.GetSourceRolePlayer(partition); ModelProtoElement p = GetElementById(sourceRP.RolePlayerId); if (p != null) { referencingMapping[p.ElementId].Add(link); } ModelProtoRolePlayer targetRP = link.GetTargetRolePlayer(partition); p = GetElementById(targetRP.RolePlayerId); if (p != null) { referencingMappingTarget[p.ElementId].Add(link); } } }
public override void ModelFinalize(CopyPaste.ModelProtoElement protoElement, CopyPaste.ModelProtoGroupMerger groupMerger) { base.ModelFinalize(protoElement, groupMerger); DomainClass domainClass = this.Store.ElementDirectory.FindElement(groupMerger.GetIdMapping(protoElement.ElementId)) as DomainClass; if (domainClass == null) { return; } if (domainClass.IsDomainModel) { domainClass.IsDomainModel = false; } if (domainClass.BaseClass != null) { ReadOnlyCollection <DomainClassReferencesBaseClass> col = DomainRoleInfo.GetElementLinks <DomainClassReferencesBaseClass>(domainClass, DomainClassReferencesBaseClass.DerivedClassDomainRoleId); if (col.Count != 1) { throw new ArgumentNullException("Domain class can only reference one base class"); } DomainClassReferencesBaseClass r = col[0]; r.InhNodeId = Guid.Empty; // otherwise node id of the source element would be used } if (domainClass.DomainModelTreeNodes.Count == 0) { RootNode node = new RootNode(domainClass.Store); node.DomainElement = domainClass; node.IsElementHolder = true; // add to the domain model diagram tree domainClass.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(node); domainClass.ModelContext.ViewContext.DomainModelTreeView.RootNodes.Add(node); } SerializationDomainClassAddRule.OnDomainClassAdded(domainClass); SerializationHelper.UpdateDerivedElementsSerializationProperties(domainClass); }
private static int SortProtoElements(ModelProtoElement x, ModelProtoElement y) { if (x.Name == "DomainClass" && y.Name != "DomainClass") return -1; else if (x.Name != "DomainClass" && y.Name == "DomainClass") return 1; return 0; }
/// <summary> /// Get all embedded proto elements for the given element. /// </summary> /// <param name="partition">Partition.</param> /// <param name="protoElement">Proto element to get all embedded elements for.</param> /// <returns>List of embedded proto elements.</returns> public List<ModelProtoElement> GetEmbeddedElements(Partition partition, ModelProtoElement protoElement) { List<ModelProtoElement> elements; this.embeddingMapping.TryGetValue(protoElement.ElementId, out elements); return elements; }
/// <summary> /// Get all embedded proto elements for the given element. /// </summary> /// <param name="partition">Partition.</param> /// <param name="protoElement">Proto element to get all embedded elements for.</param> /// <returns>List of embedded proto elements.</returns> public List<ModelProtoElement> GetEmbeddedElements(Partition partition, ModelProtoElement protoElement) { if (bNeedsInitialization) InitDictionaries(partition); List<ModelProtoElement> elements; this.embeddingMapping.TryGetValue(protoElement.ElementId, out elements); return elements; }
public override bool ModelCanMerge(CopyPaste.ModelProtoElement protoElement, CopyPaste.ModelProtoGroup protoGroup) { if (protoElement != null) { DomainClassInfo elementDomainInfo = this.Partition.DomainDataDirectory.GetDomainClass(protoElement.DomainClassId); if (elementDomainInfo.IsDerivedFrom(global::Tum.PDE.LanguageDSL.DomainClass.DomainClassId)) { if (protoGroup.Operation == ModelProtoGroupOperation.Move) { foreach (global::Tum.PDE.LanguageDSL.LibraryModelContextHasClasses link in DomainRoleInfo.GetElementLinks <global::Tum.PDE.LanguageDSL.LibraryModelContextHasClasses>(this, global::Tum.PDE.LanguageDSL.LibraryModelContextHasClasses.LibraryModelContextDomainRoleId)) { if (link.DomainClass.Id == protoElement.ElementId) { return(false); } } } return(true); } else if (elementDomainInfo.IsDerivedFrom(global::Tum.PDE.LanguageDSL.DomainRelationship.DomainClassId)) { if (protoGroup.Operation == ModelProtoGroupOperation.Move) { foreach (global::Tum.PDE.LanguageDSL.LibraryModelContextHasRelationships link in DomainRoleInfo.GetElementLinks <global::Tum.PDE.LanguageDSL.LibraryModelContextHasRelationships>(this, global::Tum.PDE.LanguageDSL.LibraryModelContextHasRelationships.LibraryModelContextDomainRoleId)) { if (link.DomainRelationship.Id == protoElement.ElementId) { return(false); } } } // see if source and target domain classes are copied here List <ModelProtoElement> elements = protoGroup.GetEmbeddedElements(this.Partition, protoElement); for (int i = 0; i < elements.Count; i++) { if (elements[i].Name == "DomainRole") { List <ModelProtoLink> links = protoGroup.GetReferenceLinks(this.Partition, elements[i]); foreach (ModelProtoLink link in links) { if (link.Name == "DomainRoleReferencesRolePlayer") { ModelProtoRolePlayer rP = link.GetTargetRolePlayer(this.Partition); // see if the target element is beeing copied or is already in the model if (!protoGroup.HasProtoElementFor(rP.RolePlayerId, this.Partition)) { ModelElement m = this.Store.ElementDirectory.FindElement(rP.RolePlayerId); if (m == null) { if (!this.MetaModel.HasElement(rP.ElementName)) { return(false); } } } } } } } return(true); } } return(false); }
/// <summary> /// Adds a proto element to the proto elements collection. /// </summary> /// <param name="protoElement">Proto element to add to the collection.</param> public void AddNewElement(ModelProtoElement protoElement) { if (!protoElements.Contains(protoElement)) protoElements.Add(protoElement); }
public List<ModelProtoLink> GetReferenceLinksTarget(Partition partition, ModelProtoElement protoElement) { if (bNeedsInitialization) InitDictionaries(partition); List<ModelProtoLink> elements; this.referencingMappingTarget.TryGetValue(protoElement.ElementId, out elements); return elements; }
/// <summary> /// Adds a proto element to the proto elements collection. /// </summary> /// <param name="protoElement">Proto element to add to the collection.</param> public void AddNewRootElement(ModelProtoElement protoElement) { if( !this.protoRootElements.Contains(protoElement)) protoRootElements.Add(protoElement); }
/// <summary> /// Constructor. /// </summary> /// <param name="protoGroup">Proto group to paste/move.</param> /// <param name="rootElement">Element to execute paste/move on.</param> public ModelProtoGroupMerger(ModelProtoGroup protoGroup, ModelElement rootElement) { this.protoGroup = protoGroup; this.validationResult = new ValidationResult(); this.idMapping = new Dictionary <Guid, Guid>(); this.embeddingMapping = new Dictionary <Guid, List <ModelProtoElement> >(); this.referencingMapping = new Dictionary <Guid, List <ModelProtoLink> >(); this.referencingMappingTarget = new Dictionary <Guid, List <ModelProtoLink> >(); this.elementMapping = new Dictionary <Guid, ModelProtoElement>(); if (protoGroup.Operation == ModelProtoGroupOperation.Move) { // move element foreach (ModelProtoElement protoElement in protoGroup.ProtoRootElements) { (rootElement as IModelMergeElements).ModelMove(protoElement, this); } return; } foreach (ModelProtoElement element in protoGroup.ProtoElements) { idMapping.Add(element.ElementId, Guid.Empty); embeddingMapping.Add(element.ElementId, new List <ModelProtoElement>()); referencingMapping.Add(element.ElementId, new List <ModelProtoLink>()); referencingMappingTarget.Add(element.ElementId, new List <ModelProtoLink>()); elementMapping.Add(element.ElementId, element); } foreach (ModelProtoLink link in protoGroup.ProtoEmbeddingLinks) { ModelProtoRolePlayer rolePlayer = link.GetSourceRolePlayer(rootElement.Store.DefaultPartition); ModelProtoElement p = GetElementById(rolePlayer.RolePlayerId); if (p != null) { embeddingMapping[p.ElementId].Add( GetElementById(link.GetTargetRolePlayer(rootElement.Store.DefaultPartition).RolePlayerId)); } } foreach (ModelProtoLink link in protoGroup.ProtoReferenceLinks) { ModelProtoRolePlayer sourceRP = link.GetSourceRolePlayer(rootElement.Store.DefaultPartition); ModelProtoElement p = GetElementById(sourceRP.RolePlayerId); if (p != null) { referencingMapping[p.ElementId].Add(link); } ModelProtoRolePlayer targetRP = link.GetTargetRolePlayer(rootElement.Store.DefaultPartition); p = GetElementById(targetRP.RolePlayerId); if (p != null) { referencingMappingTarget[p.ElementId].Add(link); } } // start merging foreach (ModelProtoElement protoElement in protoGroup.ProtoRootElements) { (rootElement as IModelMergeElements).ModelMerge(protoElement, this, true); } // process reference relationships foreach (ModelProtoLink link in protoGroup.ProtoReferenceLinks) { ModelProtoRolePlayer sourceRP = link.GetSourceRolePlayer(rootElement.Store.DefaultPartition); if (this.idMapping.ContainsKey(sourceRP.RolePlayerId)) { System.Guid id = this.idMapping[sourceRP.RolePlayerId]; if (id != Guid.Empty) { ModelElement copiedModelElement = rootElement.Store.ElementDirectory.FindElement(id); if (copiedModelElement != null) { if (copiedModelElement is IModelMergeElements) { (copiedModelElement as IModelMergeElements).ModelMerge(link, this); } } continue; } } System.Guid elementId = sourceRP.RolePlayerId; ModelElement modelElement = rootElement.Store.ElementDirectory.FindElement(elementId); if (modelElement != null) { if (modelElement is IModelMergeElements) { (modelElement as IModelMergeElements).ModelMerge(link, this); } } } // finalize merging foreach (ModelProtoElement protoElement in protoGroup.ProtoElements) { Guid id = Guid.Empty; try { id = GetIdMapping(protoElement.ElementId); } catch { id = Guid.Empty; continue; } /* * if (id == Guid.Empty) * { * ModelElement m = rootElement.Store.ElementDirectory.FindElement(id); * if (m != null) * id = m.Id; * else * continue; * }*/ ModelElement m = rootElement.Store.ElementDirectory.FindElement(id); if (m != null) { (m as IModelMergeElements).ModelFinalize(protoElement, this); } } // finalize merging foreach (ModelProtoElement protoElement in protoGroup.ProtoRootElements) { (rootElement as IModelMergeElements).ModelFinalizeMerge(protoElement, this); } }
private void FinalizeRelationshipMerge(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger) { SerializationClass sClass; if (this is ReferenceRelationship) { sClass = (this as ReferenceRelationship).SerializedReferenceRelationship; } else { sClass = (this as EmbeddingRelationship).SerializedEmbeddingRelationship; } if (protoElement.CustomArguments != null) if (protoElement.CustomArguments is DomainRelationshipSerializationInfo) { DomainRelationshipSerializationInfo info = (DomainRelationshipSerializationInfo)protoElement.CustomArguments; if (this is ReferenceRelationship) { (this as ReferenceRelationship).SerializedReferenceRelationship.IsInFullSerialization = info.IsInFullSerialization; } else { (this as EmbeddingRelationship).SerializedEmbeddingRelationship.IsInFullSerialization = info.IsInFullSerialization; (this as EmbeddingRelationship).SerializedEmbeddingRelationship.IsTargetIncludedSubmodel = info.IsTargetIncludedSubmodel; } if (info != null) { for (int i = 0; i < info.AttributesOrder.Count; i++) { #region Attributes ElementSerializationInfo eInfo = info.AttributesOrder[i] as ElementSerializationInfo; Guid newId = Guid.Empty; if (eInfo.ElementName != "SerializedIdProperty") { try { newId = groupMerger.GetIdMapping(eInfo.ElementId); } catch { newId = Guid.Empty; } if (newId == Guid.Empty) { ModelElement m = this.Store.ElementDirectory.FindElement(eInfo.ElementId); if (m != null) newId = m.Id; } } for (int y = 0; y < sClass.Attributes.Count; y++) { if (sClass.Attributes[y] is SerializedIdProperty && eInfo.ElementName == "SerializedIdProperty") { (sClass.Attributes[y] as SerializedIdProperty).OmitIdProperty = eInfo.OmitElement; if (y != i) sClass.Attributes.Move(y, i); break; } else if (eInfo.ElementName != "SerializedIdProperty" && !(sClass.Attributes[y] is SerializedIdProperty)) { SerializedDomainProperty p = sClass.Attributes[y] as SerializedDomainProperty; p.OmitProperty = eInfo.OmitElement; if (p.DomainProperty.Id == newId && y != i) { sClass.Attributes.Move(y, i); break; } } } #endregion } for (int i = 0; i < info.ChildrenOrder.Count; i++) { #region Children ElementSerializationInfo eInfo = info.ChildrenOrder[i] as ElementSerializationInfo; Guid newId = Guid.Empty; try { newId = groupMerger.GetIdMapping(eInfo.ElementId); } catch { newId = Guid.Empty; } if (newId == Guid.Empty) { ModelElement m = this.Store.ElementDirectory.FindElement(eInfo.ElementId); if (m != null) newId = m.Id; } for (int y = i; y < sClass.Children.Count; y++) { if (sClass.Children[y] is SerializedDomainProperty) { SerializedDomainProperty p = sClass.Children[y] as SerializedDomainProperty; if (p.DomainProperty.Id == newId) { p.OmitProperty = eInfo.OmitElement; if (y != i) sClass.Children.Move(y, i); break; } } } #endregion } } } }
public List<ModelProtoLink> GetReferenceLinksTarget(Partition partition, ModelProtoElement protoElement) { List<ModelProtoLink> elements; this.referencingMappingTarget.TryGetValue(protoElement.ElementId, out elements); return elements; }
/// <summary> /// Adds a proto element to the proto elements collection. /// </summary> /// <param name="protoElement">Proto element to add to the collection.</param> /// <param name="index">Index.</param> public void InsertNewRootElement(ModelProtoElement protoElement, int index) { if (!this.protoRootElements.Contains(protoElement)) protoRootElements.Insert(index, protoElement); }
private void FinalizeReferenceRelationshipMerge(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger, bool bCreateSInfo) { ReferenceRelationship refRel = this.Store.ElementDirectory.FindElement(groupMerger.GetIdMapping(protoElement.ElementId)) as ReferenceRelationship; if (bCreateSInfo) SerializationDomainRelationshipAddRule.OnReferenceRelationshipAdded(refRel); if (refRel == null) return; ModelTreeHelper.AddNewReferenceRelationship(refRel, refRel.Source.RolePlayer as DomainClass, refRel.Target.RolePlayer); }
private void FinalizeEmbeddingRelationshipsMerge(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger, bool bCreateSInfo) { EmbeddingRelationship embRel = this.Store.ElementDirectory.FindElement(groupMerger.GetIdMapping(protoElement.ElementId)) as EmbeddingRelationship; if (bCreateSInfo) SerializationDomainRelationshipAddRule.OnEmbeddingRelationshipAdded(embRel); if (embRel == null) return; ModelTreeHelper.AddNewEmbeddingRS(embRel, embRel.Source.RolePlayer as DomainClass, embRel.Target.RolePlayer, false); }
public override void ModelProcessMergeCopy(CopyPaste.ModelProtoElement protoElement, CopyPaste.ModelProtoGroup protoGroup) { base.ModelProcessMergeCopy(protoElement, protoGroup); // copy rs and target elements if required if (CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyEmbeddingTree || CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyAllTree || CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyReferenceTree) { foreach (DomainRole role in this.RolesPlayed) { if (role.Relationship is EmbeddingRelationship && role.Relationship.Source == role) { if (CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyEmbeddingTree || CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyAllTree) { ModelProtoElement e = (role.Relationship as IModelMergeElements).ModelCreateMergeCopy(protoGroup); protoGroup.AddNewRootElement(e); // continue with target element if (ImmutabilityExtensionMethods.GetLocks(role.Relationship.Target.RolePlayer) == Locks.None) { if (!protoGroup.HasProtoElementFor(role.Relationship.Target.RolePlayer.Id, this.Partition)) { ModelProtoElement d = (role.Relationship.Target.RolePlayer as IModelMergeElements).ModelCreateMergeCopy(protoGroup); protoGroup.InsertNewRootElement(d, 0); } } } } else if (role.Relationship is ReferenceRelationship && role.Relationship.Source == role) { if (CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyAllTree || CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyReferenceTree) { ModelProtoElement e = (role.Relationship as IModelMergeElements).ModelCreateMergeCopy(protoGroup); protoGroup.AddNewRootElement(e); } } } // sort proto elements: bring domain classes to the top protoGroup.SortProtoElements(SortProtoElements); } // copy order of attributes and children DomainClassSerializationInfo info = new DomainClassSerializationInfo( this.SerializedDomainClass.Children.Count, this.SerializedDomainClass.Attributes.Count); for (int i = 0; i < this.SerializedDomainClass.Attributes.Count; i++) { SerializationAttributeElement aatr = this.SerializedDomainClass.Attributes[i]; if (aatr is SerializedDomainProperty) { SerializedDomainProperty sP = aatr as SerializedDomainProperty; ElementSerializationInfo sInfo = new ElementSerializationInfo( sP.DomainProperty.Name, sP.DomainProperty.Id); if (sP.OmitProperty) { sInfo.OmitElement = true; } info.AttributesOrder.Add(sInfo); } else if (aatr is SerializedIdProperty) { SerializedIdProperty sI = aatr as SerializedIdProperty; ElementSerializationInfo sInfo = new ElementSerializationInfo("SerializedIdProperty", Guid.Empty); if (sI.OmitIdProperty) { sInfo.OmitElement = true; } info.AttributesOrder.Add(sInfo); } } for (int i = 0; i < this.SerializedDomainClass.Children.Count; i++) { SerializationElement sE = this.SerializedDomainClass.Children[i]; if (sE is SerializedReferenceRelationship) { SerializedReferenceRelationship sDomainRel = sE as SerializedReferenceRelationship; ElementSerializationInfo sInfo = new ElementSerializationInfo( sDomainRel.ReferenceRelationship.Name, sDomainRel.ReferenceRelationship.Id); if (sDomainRel.OmitRelationship) { sInfo.OmitElement = true; } info.ChildrenOrder.Add(sInfo); } else if (sE is SerializedEmbeddingRelationship) { SerializedEmbeddingRelationship sDomainRel = sE as SerializedEmbeddingRelationship; ElementSerializationInfo sInfo = new ElementSerializationInfo( sDomainRel.EmbeddingRelationship.Name, sDomainRel.EmbeddingRelationship.Id); if (sDomainRel.OmitRelationship) { sInfo.OmitElement = true; } info.ChildrenOrder.Add(sInfo); } else if (sE is SerializedDomainProperty) { SerializedDomainProperty sP = sE as SerializedDomainProperty; ElementSerializationInfo sInfo = new ElementSerializationInfo( sP.DomainProperty.Name, sP.DomainProperty.Id); if (sP.OmitProperty) { sInfo.OmitElement = true; } info.ChildrenOrder.Add(sInfo); } } protoElement.CustomArguments = info; }
public override void ModelProcessMergeCopy(ModelProtoElement protoElement, ModelProtoGroup protoGroup) { base.ModelProcessMergeCopy(protoElement, protoGroup); bool isInFull = false; bool isTargetInc = false; SerializationClass sClass; if (this is ReferenceRelationship) { sClass = (this as ReferenceRelationship).SerializedReferenceRelationship; isInFull = (this as ReferenceRelationship).SerializedReferenceRelationship.IsInFullSerialization; } else { sClass = (this as EmbeddingRelationship).SerializedEmbeddingRelationship; isInFull = (this as EmbeddingRelationship).SerializedEmbeddingRelationship.IsInFullSerialization; isTargetInc = (this as EmbeddingRelationship).SerializedEmbeddingRelationship.IsTargetIncludedSubmodel; } // copy order of attributes and children DomainRelationshipSerializationInfo info = new DomainRelationshipSerializationInfo( sClass.Children.Count, sClass.Attributes.Count); info.IsInFullSerialization = isInFull; info.IsTargetIncludedSubmodel = isTargetInc; for (int i = 0; i < sClass.Attributes.Count; i++) { SerializationAttributeElement aatr = sClass.Attributes[i]; if (aatr is SerializedDomainProperty) { SerializedDomainProperty sP = aatr as SerializedDomainProperty; ElementSerializationInfo sInfo = new ElementSerializationInfo( sP.DomainProperty.Name, sP.DomainProperty.Id); if (sP.OmitProperty) sInfo.OmitElement = true; info.AttributesOrder.Add(sInfo); } else if (aatr is SerializedIdProperty) { SerializedIdProperty sI = aatr as SerializedIdProperty; ElementSerializationInfo sInfo = new ElementSerializationInfo("SerializedIdProperty", Guid.Empty); if (sI.OmitIdProperty) sInfo.OmitElement = true; info.AttributesOrder.Add(sInfo); } } for (int i = 0; i < sClass.Children.Count; i++) { SerializationElement sE = sClass.Children[i]; if (sE is SerializedDomainProperty) { SerializedDomainProperty sP = sE as SerializedDomainProperty; ElementSerializationInfo sInfo = new ElementSerializationInfo( sP.DomainProperty.Name, sP.DomainProperty.Id); if (sP.OmitProperty) sInfo.OmitElement = true; info.ChildrenOrder.Add(sInfo); } } protoElement.CustomArguments = info; }