/// <summary> /// Gets called when the parent model element of the current model element is about to change /// </summary> /// <param name="oldParent">The old parent model element</param> /// <param name="newParent">The new parent model element</param> protected override void OnParentChanging(NMF.Models.IModelElement newParent, NMF.Models.IModelElement oldParent) { NMF.Models.Meta.INamespace oldNamespace = ModelHelper.CastAs <NMF.Models.Meta.INamespace>(oldParent); NMF.Models.Meta.INamespace newNamespace = ModelHelper.CastAs <NMF.Models.Meta.INamespace>(newParent); ValueChangedEventArgs e = new ValueChangedEventArgs(oldNamespace, newNamespace); this.OnNamespaceChanging(e); this.OnPropertyChanging("Namespace", e, _namespaceReference); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(NMF.Models.IModelElement item) { if ((this._parent.Namespace == null)) { NMF.Models.Meta.INamespace namespaceCasted = item.As <NMF.Models.Meta.INamespace>(); if ((namespaceCasted != null)) { this._parent.Namespace = namespaceCasted; return; } } }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(NMF.Models.IModelElement item) { NMF.Models.Meta.INamespace childNamespacesCasted = item.As <NMF.Models.Meta.INamespace>(); if ((childNamespacesCasted != null)) { this._parent.ChildNamespaces.Add(childNamespacesCasted); } NMF.Models.Meta.IType typesCasted = item.As <NMF.Models.Meta.IType>(); if ((typesCasted != null)) { this._parent.Types.Add(typesCasted); } }
/// <summary> /// Removes the given item from the collection /// </summary> /// <returns>True, if the item was removed, otherwise False</returns> /// <param name="item">The item that should be removed</param> public override bool Remove(NMF.Models.IModelElement item) { NMF.Models.Meta.INamespace namespaceItem = item.As <NMF.Models.Meta.INamespace>(); if (((namespaceItem != null) && this._parent.ChildNamespaces.Remove(namespaceItem))) { return(true); } NMF.Models.Meta.IType typeItem = item.As <NMF.Models.Meta.IType>(); if (((typeItem != null) && this._parent.Types.Remove(typeItem))) { return(true); } return(false); }
/// <summary> /// Gets called when the parent model element of the current model element changes /// </summary> /// <param name="oldParent">The old parent model element</param> /// <param name="newParent">The new parent model element</param> protected override void OnParentChanged(NMF.Models.IModelElement newParent, NMF.Models.IModelElement oldParent) { NMF.Models.Meta.INamespace oldNamespace = ModelHelper.CastAs <NMF.Models.Meta.INamespace>(oldParent); NMF.Models.Meta.INamespace newNamespace = ModelHelper.CastAs <NMF.Models.Meta.INamespace>(newParent); if ((oldNamespace != null)) { oldNamespace.Types.Remove(this); } if ((newNamespace != null)) { newNamespace.Types.Add(this); } ValueChangedEventArgs e = new ValueChangedEventArgs(oldNamespace, newNamespace); this.OnNamespaceChanged(e); this.OnPropertyChanged("Namespace", e, _namespaceReference); base.OnParentChanged(newParent, oldParent); }