/// <summary> /// Adds the relationships from <paramref name="nrRelationships"/> to the /// diagram. /// </summary> /// <param name="nrRelationships">The relationships to add.</param> private void AddRelationships(NRRelationships nrRelationships) { foreach (NRNesting nrNesting in nrRelationships.Nestings) { CompositeType parentType = types[nrNesting.ParentType] as CompositeType; TypeBase innerType = types[nrNesting.InnerType]; if (parentType != null && innerType != null) { diagram.AddNesting(parentType, innerType); } } foreach (NRGeneralization nrGeneralization in nrRelationships.Generalizations) { CompositeType derivedType = types[nrGeneralization.DerivedType] as CompositeType; CompositeType baseType = types[nrGeneralization.BaseType] as CompositeType; if (derivedType != null && baseType != null) { diagram.AddGeneralization(derivedType, baseType); } } foreach (NRRealization nrRealization in nrRelationships.Realizations) { CompositeType implementingType = types[nrRealization.ImplementingType] as CompositeType; InterfaceType interfaceType = types[nrRealization.BaseType] as InterfaceType; if (implementingType != null && interfaceType != null) { diagram.AddRealization(implementingType, interfaceType); } } foreach (NRAssociation nrAssociation in nrRelationships.Associations) { TypeBase first = types[nrAssociation.StartType]; TypeBase second = types[nrAssociation.EndType]; if (first != null && second != null) { AssociationRelationship associationRelationship = diagram.AddAssociation(first, second); associationRelationship.EndMultiplicity = nrAssociation.EndMultiplicity; associationRelationship.StartMultiplicity = nrAssociation.StartMultiplicity; associationRelationship.EndRole = nrAssociation.EndRole; associationRelationship.StartRole = nrAssociation.StartRole; } } }
private void CreateGeneralization() { CompositeTypeShape shape1 = first as CompositeTypeShape; CompositeTypeShape shape2 = second as CompositeTypeShape; if (shape1 != null && shape2 != null) { try { diagram.AddGeneralization(shape1.CompositeType, shape2.CompositeType); } catch (RelationshipException) { MessageBox.Show(Strings.ErrorCannotCreateRelationship); } } else { MessageBox.Show(Strings.ErrorCannotCreateRelationship); } }