Пример #1
0
            /// <summary>
            /// Adds the given element to the collection
            /// </summary>
            /// <param name="item">The item to add</param>
            public override void Add(IModelElement item)
            {
                IParameter parametersCasted = item.As <IParameter>();

                if ((parametersCasted != null))
                {
                    this._parent.Parameters.Add(parametersCasted);
                }
                if ((this._parent.DeclaringType == null))
                {
                    IStructuredType declaringTypeCasted = item.As <IStructuredType>();
                    if ((declaringTypeCasted != null))
                    {
                        this._parent.DeclaringType = declaringTypeCasted;
                        return;
                    }
                }
                if ((this._parent.Refines == null))
                {
                    IOperation refinesCasted = item.As <IOperation>();
                    if ((refinesCasted != null))
                    {
                        this._parent.Refines = refinesCasted;
                        return;
                    }
                }
            }
Пример #2
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)
        {
            IStructuredType       oldDeclaringType = ModelHelper.CastAs <IStructuredType>(oldParent);
            IStructuredType       newDeclaringType = ModelHelper.CastAs <IStructuredType>(newParent);
            ValueChangedEventArgs e = new ValueChangedEventArgs(oldDeclaringType, newDeclaringType);

            this.OnDeclaringTypeChanging(e);
            this.OnPropertyChanging("DeclaringType");
        }
Пример #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)
        {
            IStructuredType oldDeclaringType = ModelHelper.CastAs <IStructuredType>(oldParent);
            IStructuredType newDeclaringType = ModelHelper.CastAs <IStructuredType>(newParent);

            if ((oldDeclaringType != null))
            {
                oldDeclaringType.Operations.Remove(this);
            }
            if ((newDeclaringType != null))
            {
                newDeclaringType.Operations.Add(this);
            }
            ValueChangedEventArgs e = new ValueChangedEventArgs(oldDeclaringType, newDeclaringType);

            this.OnDeclaringTypeChanged(e);
            this.OnPropertyChanged("DeclaringType", e);
        }
Пример #4
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(NMF.Models.IModelElement newParent, NMF.Models.IModelElement oldParent)
        {
            IStructuredType oldDeclaringType = ModelHelper.CastAs <IStructuredType>(oldParent);
            IStructuredType newDeclaringType = ModelHelper.CastAs <IStructuredType>(newParent);

            if ((oldDeclaringType != null))
            {
                oldDeclaringType.Attributes.Remove(this);
            }
            if ((newDeclaringType != null))
            {
                newDeclaringType.Attributes.Add(this);
            }
            ValueChangedEventArgs e = new ValueChangedEventArgs(oldDeclaringType, newDeclaringType);

            this.OnDeclaringTypeChanged(e);
            this.OnPropertyChanged("DeclaringType", e, _declaringTypeReference);
            base.OnParentChanged(newParent, oldParent);
        }
Пример #5
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.DeclaringType == null))
     {
         IStructuredType declaringTypeCasted = item.As <IStructuredType>();
         if ((declaringTypeCasted != null))
         {
             this._parent.DeclaringType = declaringTypeCasted;
             return;
         }
     }
     if ((this._parent.Refines == null))
     {
         IAttribute refinesCasted = item.As <IAttribute>();
         if ((refinesCasted != null))
         {
             this._parent.Refines = refinesCasted;
             return;
         }
     }
 }