예제 #1
0
        /// <summary>
        /// Called whenever the operations collection has changed.
        /// </summary>
        /// <param name="sender">Object that has raised the event</param>
        /// <param name="e">Information about the change</param>
        protected void OnOperationsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                foreach (Operation operation in e.OldItems)
                {
                    _Operation implOp = operation as _Operation;

                    implOp.Class = null;
                    adaptedElement.OwnedOperation.Remove(implOp.Adaptee);
                }
            }
            else if (e.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (Operation operation in e.NewItems)
                {
                    _Operation implOp = operation as _Operation;
                    if (implOp == null)
                    {
                        throw new ArgumentException("An operation element created outside the model " +
                                                    "library has been added to the collection!");
                    }

                    implOp.Class = this;
                    adaptedElement.OwnedOperation.Add(implOp.Adaptee);
                }
            }
        }
예제 #2
0
        public Operation AddOperation()
        {
            _Operation operation = new _Operation(Schema);

            operations.Add(operation);
            operation.Name = "Operation" + operations.Count;

            return(operation);
        }