Ejemplo n.º 1
0
 internal void RemoveNestedChild(INestableChild element)
 {
     if (element != null && nestedChilds.Remove(element))
     {
         OnRemoveNestedChild(new NestingEventArgs(element));
     }
 }
Ejemplo n.º 2
0
        public NestingRelationship Clone(INestable parentType, INestableChild innerType)
        {
            NestingRelationship nesting = new NestingRelationship(parentType, innerType);

            nesting.CopyFrom(this);
            return(nesting);
        }
Ejemplo n.º 3
0
        /// <exception cref="RelationshipException">
        /// Cannot create relationship between the two types.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="parentType"/> or <paramref name="innerType"/> is null.
        /// </exception>
        public NestingRelationship AddNesting(INestable parentType, INestableChild innerType)
        {
            NestingRelationship nesting = new NestingRelationship(parentType, innerType);

            AddRelationship(nesting);
            return(nesting);
        }
Ejemplo n.º 4
0
 internal void AddNestedChild(INestableChild element)
 {
     if (element != null && !nestedChilds.Contains(element))
     {
         nestedChilds.Add(element);
         OnAddNestedChild(new NestingEventArgs(element));
     }
 }
Ejemplo n.º 5
0
        internal NestableChildHelper(INestableChild nestableChild)
        {
            if (nestableChild == null)
            {
                throw new ArgumentException(nameof(nestableChild));
            }

            this.nestableChild = nestableChild;
        }
Ejemplo n.º 6
0
        internal bool IsNestedAncestor(INestableChild type)
        {
            var thisNestableChild = nestable as INestableChild;

            if (thisNestableChild != null && thisNestableChild.NestingParent != null && thisNestableChild.NestingParent.IsNestedAncestor(type))
            {
                return(true);
            }
            else
            {
                return(type == thisNestableChild);
            }
        }
Ejemplo n.º 7
0
        /// <exception cref="ArgumentNullException">
        /// <paramref name="first"/> is null.-or-
        /// <paramref name="second"/> is null.
        /// </exception>
        internal NestingRelationship(INestable first, INestableChild second)
        {
            if (first == null)
            {
                throw new ArgumentNullException("first");
            }
            if (second == null)
            {
                throw new ArgumentNullException("second");
            }

            this.first  = first;
            this.second = second;
            Attach();
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 9
0
        protected override bool CloneRelationship(IDiagram diagram, Shape first, Shape second)
        {
            if (diagram.DiagramType != DiagramType.ClassDiagram)
            {
                return(false);
            }

            INestable      firstType  = first.Entity as INestable;
            INestableChild secondType = second.Entity as INestableChild;

            if (firstType != null && secondType != null)
            {
                NestingRelationship clone = nesting.Clone(firstType, secondType);
                return(((ClassDiagram)diagram).InsertNesting(clone));
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 10
0
        private void CreateNesting()
        {
            INestable      parent = first.Entity as INestable;
            INestableChild child  = second.Entity as INestableChild;

            try
            {
                if (parent == null)
                {
                    throw new RelationshipException(Strings.ErrorParentNestingNotSupported);
                }

                if (child == null)
                {
                    throw new RelationshipException(Strings.ErrorChildNestingNotSupported);
                }

                diagram.AddNesting(parent, child);
            }
            catch (RelationshipException ex)
            {
                MessageBox.Show(Strings.ErrorCannotCreateRelationship + " " + ex.Message);
            }
        }
Ejemplo n.º 11
0
 public NestingEventArgs(INestableChild element)
 {
     this.element = element;
 }
Ejemplo n.º 12
0
 public void AddNestedChild(INestableChild type)
 {
     nestableHelper.AddNestedChild(type);
 }
Ejemplo n.º 13
0
 public void AddNestedChild(INestableChild type)
 {
     nestableHelper.AddNestedChild(type);
     type.NestingParent = this;
 }
Ejemplo n.º 14
0
 public void RemoveNestedChild(INestableChild type)
 {
     nestableHelper.RemoveNestedChild(type);
     type.NestingParent = null;
 }
Ejemplo n.º 15
0
 public NestingRelationship AddNesting(INestable parentType, INestableChild innerType)
 {
     return(model.AddNesting(parentType, innerType));
 }
Ejemplo n.º 16
0
 public void RemoveNestedChild(INestableChild type)
 {
     nestableHelper.RemoveNestedChild(type);
 }
Ejemplo n.º 17
0
 public bool IsNestedAncestor(INestableChild type)
 {
     return(nestableHelper.IsNestedAncestor(type));
 }