/// <summary> /// Sets the parent for the current model element to the given element /// </summary> /// <param name="newParent">The new parent for the given element</param> private void SetParent(IModelElement newParent) { var newParentME = newParent as ModelElement; if (newParentME != parent) { var oldParent = parent; if (newParentME != null) { OnParentChanging(newParentME, parent); Uri oldUri = null; if (IsFlagSet(ModelElementFlag.RequireUris)) { oldUri = AbsoluteUri; } parent = newParentME; var newModel = newParentME.Model; var oldModel = oldParent != null ? oldParent.Model : null; if (oldParent != null) { if (EnforceModels && oldModel != null && newModel == null) { oldModel.RootElements.Add(newParentME); } } if (oldParent != null && oldParent.IsFlagSet(ModelElementFlag.RequireUris) && oldUri != null) { oldParent.OnBubbledChange(BubbledChangeEventArgs.UriChanged(this, new UriChangedEventArgs(oldUri))); } else if (bubbledChange == null) { UnregisterBubbledChangeRequest(); } if (newParentME.IsFlagSet(ModelElementFlag.RaiseBubbledChanges) || newParentME.bubbledChange != null) { RequestBubbledChanges(); } if (newParentME.IsFlagSet(ModelElementFlag.RequireUris)) { RequestUris(); OnUriChanged(oldUri); } newParentME.OnChildCreated(this); if (newModel != oldModel) { PropagateNewModel(newModel, oldModel, this); } OnParentChanged(newParentME, oldParent); } else { parent = null; var oldModel = oldParent.Model; if (bubbledChange == null) { UnregisterBubbledChangeRequest(); } if (oldModel != null) { PropagateNewModel(null, oldModel, this); } OnParentChanged(null, oldParent); } } }
public ModelElementExtensionsProxy(ModelElement element) { this.element = element; }