private void CreateAssociation(ClassType first, ClassType second)
        {
            AssociationRelationship associationRelationship = diagram.AddAssociation(first, second);

            associationRelationship.StartMultiplicity = "0..1";
            associationRelationship.EndMultiplicity   = "*";
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        public AssociationRelationship AddComposition(AssociationRelationship composition)
        {
            Shape startShape = GetShape(composition.First);
            Shape endShape   = GetShape(composition.Second);

            AddConnection(new Association(composition, startShape, endShape));
            return(composition);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        /// <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;
                }
            }
        }
예제 #9
0
        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);
            }
        }
예제 #10
0
 /// <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);
 }
예제 #11
0
 /// <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;
 }
예제 #12
0
 public bool InsertAssociation(AssociationRelationship associaton)
 {
     return(model.InsertRelationship(associaton));
 }
예제 #13
0
        /// <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;
        }
예제 #14
0
 /// <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;
 }