/// <summary> /// Performs a deep copy of the specified <see cref="AssociationSetEnd"/>. /// </summary> /// <param name="associationSetEnd">The <see cref="AssociationSetEnd"/> to deep copy.</param> /// <returns>A deep copy of the <see cref="AssociationSetEnd"/>.</returns> private static AssociationSetEnd Clone(this AssociationSetEnd associationSetEnd) { var clone = new AssociationSetEnd(associationSetEnd.AssociationEnd.RoleName, associationSetEnd.EntitySet.NameOrNull()); CopyAnnotations(clone, associationSetEnd.Annotations); return(clone); }
/// <summary> /// Initializes a new instance of the <see cref="RelationshipGroupEnd"/> class. /// </summary> /// <param name="associationSet">The association set.</param> /// <param name="associationSetEnd">The association set end.</param> public RelationshipGroupEnd(AssociationSet associationSet, AssociationSetEnd associationSetEnd) { this.EntitySet = associationSetEnd.EntitySet; this.EntityType = associationSetEnd.AssociationEnd.EntityType; this.Multiplicity = associationSet.GetOtherEnd(associationSetEnd).AssociationEnd.Multiplicity; this.associationSetEnds = new List<KeyValuePair<AssociationSet, AssociationSetEnd>>(); this.associationSetEnds.Add(new KeyValuePair<AssociationSet, AssociationSetEnd>(associationSet, associationSetEnd)); this.Candidates = new List<RelationshipCandidate>(); this.CapacitySelector = CapacityRangeSelector.GetDefaultCapacityRangeSelector(this.Multiplicity); }
/// <summary> /// Sets the capacity range selector for the specified association set and end. /// </summary> /// <param name="associationSet">The association set.</param> /// <param name="associationSetEnd">The association set end.</param> /// <param name="selector">The capacity range selector.</param> public void SetCapacityRangeSelector(AssociationSet associationSet, AssociationSetEnd associationSetEnd, Func<CapacityRange> selector) { ExceptionUtilities.CheckArgumentNotNull(associationSet, "associationSet"); ExceptionUtilities.CheckArgumentNotNull(associationSetEnd, "associationSetEnd"); this.SetCapacityRangeSelector(associationSet.Name, associationSetEnd.AssociationEnd.RoleName, selector); }
private void CompareAssociationSetEnd(AssociationSetEnd expectedEnd, AssociationSetEnd actualEnd) { this.WriteErrorIfFalse(expectedEnd.EntitySet.Name == actualEnd.EntitySet.Name, "Expected EntitySet Name to be '{0}' actual '{1}' on an associationSetEnd", expectedEnd.EntitySet.Name, actualEnd.EntitySet.Name); this.CompareAssociationEnd(expectedEnd.AssociationEnd, actualEnd.AssociationEnd); }
private AssociationSetEnd ParseAssociationSetEnd(XElement associationSetEndElement) { string roleName = associationSetEndElement.GetRequiredAttributeValue("Role"); var entitySetName = associationSetEndElement.GetRequiredAttributeValue("EntitySet"); var associationSetEnd = new AssociationSetEnd(roleName, entitySetName); this.ParseAnnotations(associationSetEnd, associationSetEndElement); return associationSetEnd; }
/// <summary> /// Gets the next entity type for association set end. /// </summary> /// <param name="associationSetEnd">The association set end.</param> /// <returns>Entity type.</returns> public EntityType GetNextEntityTypeForAssociationSetEnd(AssociationSetEnd associationSetEnd) { EntitySet entitySet = associationSetEnd.EntitySet; EntityType entityType = associationSetEnd.AssociationEnd.EntityType; Counter counter; List<EntityType> possibleTypes; if (this.entitySetsWithInheritance.TryGetValue(entitySet.Name, out possibleTypes)) { // Take into account associations between subtypes possibleTypes = possibleTypes.Where(t => t.IsKindOf(entityType)).ToList(); List<Counter> farthestFromTarget = new List<Counter>(); int maxCountRemainig = 0; this.FindFarthestFromTarget(entitySet.Name, ref maxCountRemainig, farthestFromTarget, possibleTypes.Select(t => t.Name)); if (farthestFromTarget.Count > 0) { counter = this.random.ChooseFrom(farthestFromTarget); entityType = counter.EntityType; } else { entityType = this.random.ChooseFrom(possibleTypes); } } return entityType; }
private void CompareAssociationSetEnd(AssociationSetEnd expectedEnd, AssociationSetEnd actualEnd) { this.SatisfiesEquals(expectedEnd.EntitySet.Name, actualEnd.EntitySet.Name, "AssociationEnd '{0}' EntitySet name not match.", expectedEnd.AssociationEnd.RoleName); }
/// <summary> /// Gets the other end of the association set. /// </summary> /// <param name="end">The end for which to get other end.</param> /// <returns>The other end of the association set.</returns> public AssociationSetEnd GetOtherEnd(AssociationSetEnd end) { return this.Ends.Where(e => e != end).Single(); }
/// <summary> /// Add an AssociationSetEnd to Ends collection. /// </summary> /// <param name="end">association set end to be added</param> public void Add(AssociationSetEnd end) { this.Ends.Add(end); }
/// <summary> /// Visit association set end /// </summary> /// <param name="associationSetEnd">association set end to visit</param> protected virtual void VisitAssociationSetEnd(AssociationSetEnd associationSetEnd) { this.VisitAnnotatedItem(associationSetEnd); }
/// <summary> /// Gets the other end of the association set. /// </summary> /// <param name="end">The end for which to get other end.</param> /// <returns>The other end of the association set.</returns> public AssociationSetEnd GetOtherEnd(AssociationSetEnd end) { return(this.Ends.Where(e => e != end).Single()); }
private XElement GenerateAssociationSetEnd(XNamespace xmlNamespace, AssociationSetEnd setEnd) { return new XElement( xmlNamespace + "End", new XAttribute("Role", setEnd.AssociationEnd.RoleName), new XAttribute("EntitySet", setEnd.EntitySet.Name), this.GenerateDocumentation(xmlNamespace, setEnd), this.GenerateAnnotations(xmlNamespace, setEnd)); }