private void CreateAssociation(ClassType first, ClassType second) { AssociationRelationship associationRelationship = diagram.AddAssociation(first, second); associationRelationship.StartMultiplicity = "0..1"; associationRelationship.EndMultiplicity = "*"; }
private void CreateAssociation() { TypeShape shape1 = first as TypeShape; TypeShape shape2 = second as TypeShape; if (shape1 != null && shape2 != null) { diagram.AddAssociation(shape1.TypeBase, shape2.TypeBase); } else { MessageBox.Show(Strings.ErrorCannotCreateRelationship); } }
/// <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 CreateAssociation() { if (First is TypeShape shape1 && Second is TypeShape shape2) { Diagram.AddAssociation(shape1.TypeBase, shape2.TypeBase); }