public override Element Clone(Model targetModel, ElementCopiesMap createdCopies) { if (ParentAssociation == null) { throw new InvalidOperationException("Parent association of class union can not be null"); } PSMClassUnion clone = new _PSMClassUnion(targetModel.Schema); return(clone); }
public override void FillCopy(Element copyElement, Model targetModel, ElementCopiesMap createdCopies) { base.FillCopy(copyElement, targetModel, createdCopies); _PSMClassUnion copyPSMClassUnion = (_PSMClassUnion)copyElement; if (ParentAssociation != null && createdCopies.ContainsKey(ParentAssociation)) { copyPSMClassUnion.ParentAssociation = createdCopies[ParentAssociation] as PSMAssociation; } if (ParentUnion != null && createdCopies.ContainsKey(ParentUnion)) { copyPSMClassUnion.ParentUnion = createdCopies[ParentUnion] as PSMClassUnion; } }
/// <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; } } } }
public PSMClassUnion CreateClassUnion() { PSMClassUnion union = new _PSMClassUnion(Schema); return(union); }