Example #1
0
        /// <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);
        }
Example #2
0
 /// <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;
         }
     }
 }
Example #3
0
        /// <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);
        }
Example #4
0
 public HeightObserver(IPersonRegister p)
 {
     height = 0;
     this.p = p;
     p.Attach(this);
 }
Example #5
0
 public YearObserver(IPersonRegister p)
 {
     ageInYears = 0;
     this.p     = p;
     p.Attach(this);
 }
Example #6
0
 public MonthObserver(IPersonRegister p)
 {
     this.p = p;
     p.Attach(this);
 }
Example #7
0
 public DayObserver(IPersonRegister p)
 {
     ageInDays = 0;
     this.p    = p;
     p.Attach(this);
 }