コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
 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);          
 }
コード例 #5
0
ファイル: XsdlParserBase.cs プロジェクト: larsenjo/odata.net
        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;
        }
コード例 #6
0
        /// <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;
        }
コード例 #7
0
 private void CompareAssociationSetEnd(AssociationSetEnd expectedEnd, AssociationSetEnd actualEnd)
 {
     this.SatisfiesEquals(expectedEnd.EntitySet.Name, actualEnd.EntitySet.Name, "AssociationEnd '{0}' EntitySet name not match.", expectedEnd.AssociationEnd.RoleName);
 }
コード例 #8
0
ファイル: AssociationSet.cs プロジェクト: AlineGuan/odata.net
 /// <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();
 }
コード例 #9
0
ファイル: AssociationSet.cs プロジェクト: AlineGuan/odata.net
 /// <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);
 }
コード例 #10
0
 /// <summary>
 /// Visit association set end
 /// </summary>
 /// <param name="associationSetEnd">association set end to visit</param>
 protected virtual void VisitAssociationSetEnd(AssociationSetEnd associationSetEnd)
 {
     this.VisitAnnotatedItem(associationSetEnd);
 }
コード例 #11
0
 /// <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);
 }
コード例 #12
0
 /// <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());
 }
コード例 #13
0
 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));
 }