/// <summary> /// Called whenever the stereotypes collection has changed. /// </summary> /// <param name="sender">Object that has raised the event</param> /// <param name="e">Information about the change</param> protected void OnStereotypesChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { foreach (Stereotype st in e.NewItems) { _Stereotype implSt = st as _Stereotype; if (st == null) { throw new ArgumentException("A stereotype element created outside the model library " + "has been added to the collection!"); } adaptedElement.OwnedStereotype.Add(implSt.Adaptee); implSt.Package = this; } } else if (e.Action == NotifyCollectionChangedAction.Remove) { foreach (Stereotype st in e.OldItems) { _Stereotype implSt = st as _Stereotype; adaptedElement.OwnedStereotype.Remove(implSt.Adaptee); implSt.Package = null; } } }
public Stereotype AddStereotype() { _Stereotype st = new _Stereotype(Schema); stereotypes.Add(st); st.Name = "Stereotype" + stereotypes.Count; return(st); }
/// <summary> /// Creates an instance of the given stereotype. /// </summary> /// <param name="stereotype"> /// Reference to the stereotype class. /// </param> /// <param name="_schema"> /// Reference to the Schema instance that is the top /// of this model hierarchy. /// </param> public _StereotypeInstance(_Stereotype stereotype, Schema _schema) : base(_schema, StereotypeTarget.InstanceSpecification) { adaptedElement = NUml.Uml2.Create.InstanceSpecification(); adaptedElement.Name = stereotype.Name; adaptedElement.Classifier.Add(stereotype.Adaptee); this.stereotype = stereotype; List <InstantiatedProperty> tmpList = new List <InstantiatedProperty>(); foreach (Property property in stereotype.Attributes) { _InstantiatedProperty tmpProperty = new _InstantiatedProperty(property, Schema); tmpList.Add(tmpProperty); adaptedElement.Slot.Add(tmpProperty.Adaptee); tmpProperty.Adaptee.OwningInstance = adaptedElement; } properties = new ReadOnlyCollection <InstantiatedProperty>(tmpList); }