private void CreateAssociation(ClassType first, ClassType second) { AssociationRelationship associationRelationship = diagram.AddAssociation(first, second); associationRelationship.StartMultiplicity = "0..1"; associationRelationship.EndMultiplicity = "*"; }
/// <exception cref="ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is null. /// </exception> public AssociationRelationship AddAssociation(TypeBase first, TypeBase second) { AssociationRelationship association = new AssociationRelationship(first, second); AddRelationship(association); return(association); }
/// <exception cref="ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is null. /// </exception> public AssociationRelationship AddComposition(TypeBase first, TypeBase second) { AssociationRelationship composition = new AssociationRelationship( first, second, AssociationType.Composition); AddRelationship(composition); return(composition); }
public AssociationRelationship AddComposition(AssociationRelationship composition) { Shape startShape = GetShape(composition.First); Shape endShape = GetShape(composition.Second); AddConnection(new Association(composition, startShape, endShape)); return(composition); }
public bool InsertAssociation(AssociationRelationship associaton) { if (associaton != null && !model.Relationships.Contains(associaton) && model.Entities.Contains(associaton.First) && model.Entities.Contains(associaton.Second)) { AddAssociation(associaton); return(true); } return(false); }
protected override bool CloneRelationship(Diagram diagram, Shape first, Shape second) { var firstType = first.Entity as TypeBase; var secondType = second.Entity as TypeBase; if (firstType != null && secondType != null) { var clone = AssociationRelationship.Clone(firstType, secondType); return(diagram.InsertAssociation(clone)); } return(false); }
public TestModelBuilder AddProperty(string typeName, string propertyName, string propertyTypeName) { var ownerTypeNode = GetNodeByName(typeName); var propertyNode = new PropertyNode(ModelNodeId.Create(), propertyName); ModelService.AddNode(propertyNode, ownerTypeNode); ModelService.AddItemToCurrentGroup(propertyNode); var propertyTypeNode = GetNodeByName(propertyTypeName); var association = new AssociationRelationship(ModelRelationshipId.Create(), propertyNode, propertyTypeNode); ModelService.AddRelationship(association); return(this); }
/// <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) { INestable parentType = types[nrNesting.ParentType] as INestable; INestableChild 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; } } }
protected override bool CloneRelationship(IDiagram diagram, Shape first, Shape second) { if (diagram.DiagramType != DiagramType.ClassDiagram) { return(false); } TypeBase firstType = first.Entity as TypeBase; TypeBase secondType = second.Entity as TypeBase; if (firstType != null && secondType != null) { AssociationRelationship clone = association.Clone(firstType, secondType); return(((ClassDiagram)diagram).InsertAssociation(clone)); } else { return(false); } }
/// <exception cref="ArgumentNullException"> /// <paramref name="association"/> is null.-or- /// <paramref name="startShape"/> is null.-or- /// <paramref name="endShape"/> is null. /// </exception> public Association(AssociationRelationship association, Shape startShape, Shape endShape) : base(association, startShape, endShape) { this.association = association; association.Reversed += new EventHandler(association_Reversed); }
/// <exception cref="ArgumentNullException"> /// <paramref name="association" /> is null.-or- /// <paramref name="startShape" /> is null.-or- /// <paramref name="endShape" /> is null. /// </exception> public Association(AssociationRelationship association, Shape startShape, Shape endShape) : base(association, startShape, endShape) { AssociationRelationship = association; association.Reversed += association_Reversed; }
public bool InsertAssociation(AssociationRelationship associaton) { return(model.InsertRelationship(associaton)); }
/// <exception cref="ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is null. /// </exception> public AssociationRelationship AddComposition(TypeBase first, TypeBase second) { AssociationRelationship composition = new AssociationRelationship( first, second, AssociationType.Composition); AddRelationship(composition); return composition; }
/// <exception cref="ArgumentNullException"> /// <paramref name="first"/> or <paramref name="second"/> is null. /// </exception> public AssociationRelationship AddAssociation(TypeBase first, TypeBase second) { AssociationRelationship association = new AssociationRelationship(first, second); AddRelationship(association); return association; }