public static void OnEmbeddingRelationshipAdded(EmbeddingRelationship embeddingRelationship)
        {
            #region Check Paramaters
            if (embeddingRelationship.Source == null)
            {
                throw new ArgumentNullException("embeddingRelationship.Source");
            }

            if (embeddingRelationship.Target == null)
            {
                throw new ArgumentNullException("embeddingRelationship.Target");
            }

            if (!(embeddingRelationship.Source.RolePlayer is DomainClass))
            {
                throw new ArgumentNullException("embeddingRelationship.Source.RolePlayer needs to be DomainClass");
            }

            if (!(embeddingRelationship.Target.RolePlayer is DomainClass))
            {
                throw new ArgumentNullException("embeddingRelationship.Target.RolePlayer needs to be DomainClass");
            }
            #endregion

            // add serialization info
            SerializedDomainClass child;
            if ((embeddingRelationship.Target.RolePlayer as DomainClass).SerializedDomainClass == null)
            {
                child             = new SerializedDomainClass(embeddingRelationship.Store);
                child.DomainClass = embeddingRelationship.Target.RolePlayer as DomainClass;
                (embeddingRelationship.Target.RolePlayer as DomainClass).ModelContext.SerializationModel.Children.Add(child);

                SerializationHelper.AddSerializationDomainProperties(embeddingRelationship.Store, embeddingRelationship.Target.RolePlayer);
            }
            else
            {
                child = (embeddingRelationship.Target.RolePlayer as DomainClass).SerializedDomainClass;
            }

            // Add properties and id attribute and set serialization form for embedding relationship.
            SerializedEmbeddingRelationship embChild = new SerializedEmbeddingRelationship(embeddingRelationship.Store);
            embChild.EmbeddingRelationship = embeddingRelationship;
            embChild.IsInFullSerialization = false;
            embChild.SerializationName     = embeddingRelationship.SerializationName;
            SerializationHelper.AddSerializationDomainProperties(embeddingRelationship.Store, embeddingRelationship);

            embeddingRelationship.ModelContext.SerializationModel.Children.Add(embChild);
            embChild.Children.Add(child);

            // Add connection between roleplayers, to reflect it onto the serialization model.
            SerializationClass sourceSerializationClass = (embeddingRelationship.Source.RolePlayer as DomainClass).SerializedDomainClass;
            sourceSerializationClass.Children.Add(embChild);

            // update derived roles
            SerializationHelper.UpdateDerivedElementsSerializationDomainRoles(embeddingRelationship.Source.RolePlayer);
        }
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            SerializedEmbeddingRelationship serializedEmbeddingRelationship = e.ModelElement as SerializedEmbeddingRelationship;

            if (serializedEmbeddingRelationship != null)
            {
                if (e.DomainProperty.Id == SerializedEmbeddingRelationship.SerializationNameDomainPropertyId)
                {
                    if (serializedEmbeddingRelationship.IsSerializationNameTracking == TrackingEnum.True)
                    {
                        serializedEmbeddingRelationship.IsSerializationNameTracking = TrackingEnum.False;
                    }
                    else if (serializedEmbeddingRelationship.IsSerializationNameTracking == TrackingEnum.IgnoreOnce)
                    {
                        serializedEmbeddingRelationship.IsSerializationNameTracking = TrackingEnum.True;
                    }

                    if (serializedEmbeddingRelationship.EmbeddingRelationship.SerializationName != serializedEmbeddingRelationship.SerializationName)
                    {
                        serializedEmbeddingRelationship.EmbeddingRelationship.SerializationName           = serializedEmbeddingRelationship.SerializationName;
                        serializedEmbeddingRelationship.EmbeddingRelationship.IsSerializationNameTracking = serializedEmbeddingRelationship.IsSerializationNameTracking;
                    }
                }
            }
        }
        /// <summary>
        /// Updates the domain roles of the given element. (Roles from derived elements are included here).
        /// </summary>
        /// <param name="store">Store containing the domain model.</param>
        /// <param name="serializationElement"></param>
        /// <param name="domainClass"></param>
        public static void UpdateSerializationDomainRoles(Store store, SerializedDomainClass serializationElement, DomainClass domainClass)
        {
            if (serializationElement == null || domainClass == null)
            {
                return;
            }

            //if (!serializationElement.DomainClass.ParentModelContext.MetaModel.IsTopMost)
            //    return;

            List <SerializationElement> handledRS = new List <SerializationElement>();

            // get roles
            DomainClass           temp        = domainClass;
            SerializedDomainClass tempElement = serializationElement;

            while (temp != null && tempElement != null)
            {
                foreach (SerializationElement sP in tempElement.Children)
                {
                    if (sP is SerializedReferenceRelationship || sP is SerializedEmbeddingRelationship)
                    {
                        // see whether the relationship is abstract or not. If it is abstract, than we dont
                        // need to add its role players
                        DomainRelationship relationship   = null;
                        SerializedReferenceRelationship s = sP as SerializedReferenceRelationship;
                        if (s != null)
                        {
                            relationship = s.ReferenceRelationship;
                            if (s.ReferenceRelationship.InheritanceModifier == InheritanceModifier.Abstract && s.ReferenceRelationship.Source.RolePlayer != domainClass)
                            {
                                continue;
                            }
                        }

                        SerializedEmbeddingRelationship sE = sP as SerializedEmbeddingRelationship;
                        if (sE != null)
                        {
                            relationship = sE.EmbeddingRelationship;
                            if (sE.EmbeddingRelationship.InheritanceModifier == InheritanceModifier.Abstract && sE.EmbeddingRelationship.Source.RolePlayer != domainClass)
                            {
                                continue;
                            }
                        }

                        // see if the current element is still active
                        bool bActive = false;
                        foreach (DomainRole role in temp.RolesPlayed)
                        {
                            if (role.Relationship.Source == role && role.Relationship == relationship)
                            {
                                bActive = true;
                                continue;
                            }
                        }
                        if (!bActive)
                        {
                            continue;
                        }

                        handledRS.Add(sP);

                        if (tempElement != serializationElement)
                        {
                            // see if we already have this element embedded
                            bool bAdd = true;
                            foreach (SerializationElement elem in serializationElement.Children)
                            {
                                if (elem == sP)
                                {
                                    bAdd = false;
                                    break;
                                }
                            }

                            if (bAdd)
                            {
                                serializationElement.Children.Add(sP);
                            }
                        }
                    }
                }

                temp = temp.BaseClass;
                if (temp != null)
                {
                    tempElement = temp.SerializedDomainClass;
                }
                else
                {
                    tempElement = null;
                }
            }

            // remove unneded rs
            List <SerializationElement> toRemove = new List <SerializationElement>();

            foreach (SerializationElement sP in serializationElement.Children)
            {
                if (sP is SerializedReferenceRelationship || sP is SerializedEmbeddingRelationship)
                {
                    if (!handledRS.Contains(sP))
                    {
                        toRemove.Add(sP);
                    }
                }
            }

            foreach (SerializationElement sP in toRemove)
            {
                serializationElement.Children.Remove(sP);
            }
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        public static void PostProcessModelLoad(MetaModel model)
        {
            // package and custom editor GUIDs
            if (model.PackageGuid == null || model.PackageGuid == Guid.Empty)
            {
                model.PackageGuid = Guid.NewGuid();
            }
            if (model.CustomExtensionGuid == null || model.CustomExtensionGuid == Guid.Empty)
            {
                model.CustomExtensionGuid = Guid.NewGuid();
            }


            #region relationship targets fixup
            ReadOnlyCollection <DomainRelationship> rels = model.AllRelationships;
            foreach (DomainRelationship rel in rels)
            {
                if (rel.Target.RolePlayer == null)
                {
                    ReferenceRelationship referenceRelationship = rel as ReferenceRelationship;
                    if (referenceRelationship != null)
                    {
                        if (referenceRelationship.ReferenceRSNode != null)
                        {
                            referenceRelationship.ReferenceRSNode.Delete();
                        }

                        if (referenceRelationship.SerializedReferenceRelationship != null)
                        {
                            referenceRelationship.SerializedReferenceRelationship.Delete();
                        }
                    }

                    EmbeddingRelationship embeddingRelationship = rel as EmbeddingRelationship;
                    if (embeddingRelationship != null)
                    {
                        if (embeddingRelationship.EmbeddingRSNode != null)
                        {
                            embeddingRelationship.EmbeddingRSNode.Delete();
                        }

                        if (embeddingRelationship.SerializedEmbeddingRelationship != null)
                        {
                            embeddingRelationship.SerializedEmbeddingRelationship.Delete();
                        }
                    }

                    rel.Delete();
                }
            }
            #endregion

            #region inconsistent serialization elements
            foreach (BaseModelContext context in model.ModelContexts)
            {
                if (context is LibraryModelContext)
                {
                    LibraryModelContext lib = context as LibraryModelContext;
                    if (lib.SerializationModel != null)
                    {
                        for (int i = lib.SerializationModel.Children.Count - 1; i >= 0; i--)
                        {
                            SerializationClass c = lib.SerializationModel.Children[i];
                            if (c is SerializedDomainClass)
                            {
                                SerializedDomainClass s = c as SerializedDomainClass;
                                if (s.DomainClass == null)
                                {
                                    s.Delete();
                                }

                                continue;
                            }
                            else if (c is SerializedEmbeddingRelationship)
                            {
                                SerializedEmbeddingRelationship s = c as SerializedEmbeddingRelationship;
                                if (s.EmbeddingRelationship == null)
                                {
                                    s.Delete();
                                }

                                continue;
                            }
                            else if (c is SerializedReferenceRelationship)
                            {
                                SerializedReferenceRelationship s = c as SerializedReferenceRelationship;
                                if (s.ReferenceRelationship == null)
                                {
                                    s.Delete();
                                }

                                continue;
                            }

                            // element has not been deleted, see if its properties are ok
                            for (int y = c.Properties.Count - 1; y >= 0; y--)
                            {
                                if (c.Properties[y] == null)
                                {
                                    c.Properties[y].Delete();
                                }
                            }
                        }
                    }
                }
            }
            #endregion

            #region derived classes serialization items fixup
            if (model.MetaModelLibraries.Count > 0)
            {
                ReadOnlyCollection <ModelElement> elements = model.Store.ElementDirectory.FindElements(DomainClassReferencesBaseClass.DomainClassId);
                foreach (ModelElement m in elements)
                {
                    DomainClassReferencesBaseClass con = m as DomainClassReferencesBaseClass;
                    if (con != null)
                    {
                        if (con.BaseClass != null)
                        {
                            if (con.BaseClass.ModelContext.MetaModel != model)
                            {
                                foreach (DomainClass derivedClass in con.BaseClass.DerivedClasses)
                                {
                                    FixUpDerivedClasses(derivedClass, model);
                                }
                            }
                        }
                    }
                }

                ReadOnlyCollection <ModelElement> elementsCon = model.Store.ElementDirectory.FindElements(DomainRelationshipReferencesBaseRelationship.DomainClassId);
                foreach (ModelElement m in elementsCon)
                {
                    DomainRelationshipReferencesBaseRelationship con = m as DomainRelationshipReferencesBaseRelationship;
                    if (con != null)
                    {
                        if (con.BaseRelationship != null)
                        {
                            if (con.BaseRelationship.ModelContext.MetaModel != model)
                            {
                                foreach (DomainRelationship derivedClass in con.BaseRelationship.DerivedRelationships)
                                {
                                    FixUpDerivedRelationships(derivedClass, model);
                                }
                            }
                        }
                    }
                }
            }
            #endregion

            #region check if model contains all required elements
            // property grid editors
            if (model.PropertyGridEditors.Count == 0)
            {
                FixUpPropertyGridEditors(model);
            }

            // domain types
            if (model.DomainTypes.Count == 0)
            {
                FixUpDomainTypes(model);
            }

            // model context
            if (model.ModelContexts.Count == 0)
            {
                FixUpModelContext(model);
            }

            // validation
            if (model.Validation == null)
            {
                model.Validation = new Validation(model.Store);
            }

            if (model.View == null)
            {
                model.View = new View(model.Store);
            }

            if (model.View.ModelTree == null)
            {
                model.View.ModelTree = new ModelTree(model.Store);
            }

            foreach (BaseModelContext mContext in model.ModelContexts)
            {
                if (mContext is LibraryModelContext)
                {
                    LibraryModelContext m = mContext as LibraryModelContext;
                    if (m.DiagramClasses.Count == 0 && m is ModelContext)
                    {
                        DesignerDiagramClass ddC = new DesignerDiagramClass(model.Store);
                        ddC.Name  = "DesignerDiagram";
                        ddC.Title = "Designer";

                        m.DiagramClasses.Add(ddC);
                    }

                    if (m.ViewContext == null)
                    {
                        m.ViewContext = new ViewContext(model.Store);
                        m.ViewContext.DomainModelTreeView = new DomainModelTreeView(model.Store);
                        m.ViewContext.DiagramView         = new DiagramView(model.Store);

                        model.View.ViewContexts.Add(m.ViewContext);

                        FixUpDomainModelTreeView(m);
                        FixUpDiagramView(m);
                    }

                    if (m.ViewContext.DiagramView == null || m.ViewContext.DomainModelTreeView == null)
                    {
                        if (m.ViewContext.DomainModelTreeView == null)
                        {
                            m.ViewContext.DomainModelTreeView = new DomainModelTreeView(model.Store);
                            FixUpDomainModelTreeView(m);
                        }

                        if (m.ViewContext.DiagramView == null)
                        {
                            m.ViewContext.DiagramView = new DiagramView(model.Store);
                            FixUpDiagramView(m);
                        }
                    }

                    // diagram class view for designer diagram
                    if (m.ViewContext.DiagramView.DiagramClassViews.Count == 0 && m is ModelContext)
                    {
                        DiagramClassView vm = new DiagramClassView(model.Store);
                        vm.IsExpanded = true;
                        foreach (DiagramClass d in m.DiagramClasses)
                        {
                            if (d is DesignerDiagramClass)
                            {
                                vm.DiagramClass = d;
                                break;
                            }
                        }

                        m.ViewContext.DiagramView.DiagramClassViews.Add(vm);
                    }

                    // serialization
                    if (m.SerializationModel == null)
                    {
                        m.SerializationModel = new SerializationModel(model.Store);
                    }

                    // serialized domain model
                    if (m is ModelContext)
                    {
                        if (m.SerializationModel.SerializedDomainModel == null)
                        {
                            FixUpSerializedDomainModel(m as ModelContext);
                        }
                    }
                }
            }
            #endregion

            // view ids.
            if (model.View != null)
            {
                if (model.View.ModelTreeId == null || model.View.ModelTreeId == Guid.Empty)
                {
                    model.View.ModelTreeId = Guid.NewGuid();
                }

                if (model.View.DependenciesViewId == null || model.View.DependenciesViewId == Guid.Empty)
                {
                    model.View.DependenciesViewId = Guid.NewGuid();
                }

                if (model.View.ErrorListId == null || model.View.ErrorListId == Guid.Empty)
                {
                    model.View.ErrorListId = Guid.NewGuid();
                }

                if (model.View.PropertyGridId == null || model.View.PropertyGridId == Guid.Empty)
                {
                    model.View.PropertyGridId = Guid.NewGuid();
                }

                if (model.View.SearchId == null || model.View.SearchId == Guid.Empty)
                {
                    model.View.SearchId = Guid.NewGuid();
                }

                if (model.View.SearchResultId == null || model.View.SearchResultId == Guid.Empty)
                {
                    model.View.SearchResultId = Guid.NewGuid();
                }

                if (model.View.PluginWindowId == null || model.View.PluginWindowId == Guid.Empty)
                {
                    model.View.PluginWindowId = Guid.NewGuid();
                }
            }
        }
Beispiel #6
0
        private void FinalizeDomainClassMerge(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger)
        {
            DomainClass domainClass = this.Store.ElementDirectory.FindElement(groupMerger.GetIdMapping(protoElement.ElementId)) as DomainClass;

            if (domainClass == null)
            {
                return;
            }

            if (protoElement.CustomArguments != null)
            {
                if (protoElement.CustomArguments is DomainClassSerializationInfo)
                {
                    DomainClassSerializationInfo info = (DomainClassSerializationInfo)protoElement.CustomArguments;
                    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 < domainClass.SerializedDomainClass.Attributes.Count; y++)
                            {
                                if (domainClass.SerializedDomainClass.Attributes[y] is SerializedIdProperty && eInfo.ElementName == "SerializedIdProperty")
                                {
                                    (domainClass.SerializedDomainClass.Attributes[y] as SerializedIdProperty).OmitIdProperty = eInfo.OmitElement;
                                    if (y != i)
                                    {
                                        domainClass.SerializedDomainClass.Attributes.Move(y, i);
                                    }
                                    break;
                                }
                                else if (eInfo.ElementName != "SerializedIdProperty" && !(domainClass.SerializedDomainClass.Attributes[y] is SerializedIdProperty))
                                {
                                    SerializedDomainProperty p = domainClass.SerializedDomainClass.Attributes[y] as SerializedDomainProperty;
                                    p.OmitProperty = eInfo.OmitElement;
                                    if (p.DomainProperty.Id == newId && y != i)
                                    {
                                        domainClass.SerializedDomainClass.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 < domainClass.SerializedDomainClass.Children.Count; y++)
                            {
                                if (domainClass.SerializedDomainClass.Children[y] is SerializedReferenceRelationship)
                                {
                                    SerializedReferenceRelationship sDomainRel = domainClass.SerializedDomainClass.Children[y] as SerializedReferenceRelationship;
                                    if (sDomainRel.ReferenceRelationship.Id == newId)
                                    {
                                        sDomainRel.OmitRelationship = eInfo.OmitElement;

                                        if (y != i)
                                        {
                                            domainClass.SerializedDomainClass.Children.Move(y, i);
                                        }
                                        break;
                                    }
                                }
                                else if (domainClass.SerializedDomainClass.Children[y] is SerializedEmbeddingRelationship)
                                {
                                    SerializedEmbeddingRelationship sDomainRel = domainClass.SerializedDomainClass.Children[y] as SerializedEmbeddingRelationship;
                                    if (sDomainRel.EmbeddingRelationship.Id == newId)
                                    {
                                        sDomainRel.OmitRelationship = eInfo.OmitElement;

                                        if (y != i)
                                        {
                                            domainClass.SerializedDomainClass.Children.Move(y, i);
                                        }
                                        break;
                                    }
                                }
                                else if (domainClass.SerializedDomainClass.Children[y] is SerializedDomainProperty)
                                {
                                    SerializedDomainProperty p = domainClass.SerializedDomainClass.Children[y] as SerializedDomainProperty;
                                    if (p.DomainProperty.Id == newId)
                                    {
                                        p.OmitProperty = eInfo.OmitElement;

                                        if (y != i)
                                        {
                                            domainClass.SerializedDomainClass.Children.Move(y, i);
                                        }
                                        break;
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                }
            }
        }