/// <summary> /// Check and insert new EntityTree to the list. /// Set it's dependant and principal entities. /// </summary> /// <param name="firstEntity">First side entity instance</param> /// <param name="secondEntity">Second side entity instance</param> /// <param name="secondEntityOwner">Second side entity's owner instance</param> /// <param name="entityRelationDirection">How does first entity depends on second entity? Eitehr Principal or Dependant</param> /// <param name="lastRecursionReturn">Holds all dependant and principal objects and owner of the entity and it's all child entities recursively</param> /// <returns> /// If the first entity was not in the list, true; otherwise, false. /// The first entities properties will be checked in case of True. /// </returns> private static bool CheckAndInsertIntoTreeList( object firstEntity, object secondEntity, object secondEntityOwner, EntityRelationDirection entityRelationDirection, List <EntityTree> lastRecursionReturn) { var firstEntityTree = lastRecursionReturn.FirstOrDefault(x => x.Entity.Equals(firstEntity)); var secondEntityTree = lastRecursionReturn.FirstOrDefault(x => x.Entity.Equals(secondEntity)); var isResursionNeeded = firstEntityTree == null; if (firstEntityTree == null) { firstEntityTree = new EntityTree(firstEntity, secondEntity); lastRecursionReturn.Add(firstEntityTree); } if (secondEntityTree == null) { secondEntityTree = new EntityTree(secondEntity, secondEntityOwner); lastRecursionReturn.Add(secondEntityTree); } if (entityRelationDirection == EntityRelationDirection.Dependant) { firstEntityTree.DirectPrincipals.Add(secondEntityTree); secondEntityTree.DirectDependants.Add(firstEntityTree); } else { firstEntityTree.DirectDependants.Add(secondEntityTree); secondEntityTree.DirectPrincipals.Add(firstEntityTree); } return(isResursionNeeded); }
public EntityRelationType(string name, ModelRelationshipType type, EntityRelationDirection direction) { Name = name; Type = type; Direction = direction; }
public EntityRelationType(string name, ModelRelationshipClassifier classifier, ModelRelationshipStereotype stereotype, EntityRelationDirection direction) : this(name, new ModelRelationshipType(classifier, stereotype), direction) { }
public bool IsEntityInRelationship(IModelEntity entity, EntityRelationDirection direction) { return((direction == EntityRelationDirection.Outgoing && entity == Source) || (direction == EntityRelationDirection.Incoming && entity == Target)); }