/// <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(IModelElement newParent, IModelElement oldParent) { IPersonRegister oldPersonsInverse = ModelHelper.CastAs <IPersonRegister>(oldParent); IPersonRegister newPersonsInverse = ModelHelper.CastAs <IPersonRegister>(newParent); ValueChangedEventArgs e = new ValueChangedEventArgs(oldPersonsInverse, newPersonsInverse); this.OnPersonsInverseChanging(e); this.OnPropertyChanging("PersonsInverse", e, _personsInverseReference); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.PersonsInverse == null)) { IPersonRegister personsInverseCasted = item.As <IPersonRegister>(); if ((personsInverseCasted != null)) { this._parent.PersonsInverse = personsInverseCasted; return; } } }
/// <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(IModelElement newParent, IModelElement oldParent) { IPersonRegister oldPersonsInverse = ModelHelper.CastAs <IPersonRegister>(oldParent); IPersonRegister newPersonsInverse = ModelHelper.CastAs <IPersonRegister>(newParent); if ((oldPersonsInverse != null)) { oldPersonsInverse.Persons.Remove(this); } if ((newPersonsInverse != null)) { newPersonsInverse.Persons.Add(this); } ValueChangedEventArgs e = new ValueChangedEventArgs(oldPersonsInverse, newPersonsInverse); this.OnPersonsInverseChanged(e); this.OnPropertyChanged("PersonsInverse", e, _personsInverseReference); base.OnParentChanged(newParent, oldParent); }
public HeightObserver(IPersonRegister p) { height = 0; this.p = p; p.Attach(this); }
public YearObserver(IPersonRegister p) { ageInYears = 0; this.p = p; p.Attach(this); }
public MonthObserver(IPersonRegister p) { this.p = p; p.Attach(this); }
public DayObserver(IPersonRegister p) { ageInDays = 0; this.p = p; p.Attach(this); }