Exemple #1
0
        /// <summary>
        /// Called whenever the PSM classes collection has changed.
        /// </summary>
        /// <param name="sender">Object that has raised the event</param>
        /// <param name="e">Information about the change</param>
        protected void OnPSMClassesChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (PSMClass cls in e.NewItems)
                {
                    _PSMClass implClass = cls as _PSMClass;
                    if (implClass == null)
                    {
                        psmClasses.Remove(cls);
                        throw new ArgumentException("A PSMClass created outside the model library was added " +
                                                    "to the PSMClasses collection!");
                    }

                    adaptedElement.OwnedType.Add(implClass.AdaptedClass);
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                foreach (PSMClass cls in e.OldItems)
                {
                    adaptedElement.OwnedType.Remove((cls as _PSMClass).AdaptedClass);
                }
            }
        }
Exemple #2
0
        public PSMClass DerivePSMClass()
        {
            _PSMClass psm = new _PSMClass(this, Schema);

            derivedPSMClasses.Add(psm);
            package.PSMClasses.Add(psm);

            return(psm);
        }
Exemple #3
0
        /// <summary>
        /// Occurs when the Components collection has changed.
        /// </summary>
        /// <param name="sender">Object that has raised the event</param>
        /// <param name="e">Information about the change</param>
        protected void OnComponentsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (PSMAssociationChild child in e.NewItems)
                {
                    if (child is PSMClassUnion)
                    {
                        throw new XCaseException("Class union can not be a component of another class union.");
                    }

                    if (child.ParentAssociation != null)
                    {
                        //child.ParentAssociation.RemoveMeFromModel();
                    }

                    _PSMClass implClass = child as _PSMClass;
                    if (implClass != null)
                    {
                        implClass.ParentUnion = this;
                    }
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                foreach (PSMAssociationChild child in e.OldItems)
                {
                    if (child is _PSMClass)
                    {
                        (child as _PSMClass).ParentUnion = null;
                    }
                    _PSMClassUnion childUnion = child as _PSMClassUnion;
                    if (childUnion != null)
                    {
                        childUnion.ParentUnion = null;
                    }
                }
            }
        }