Ejemplo n.º 1
0
        /// <summary>
        ///     See whether the AssociationIdentityForAssociationSetMapping other contains a "covering" for this
        ///     i.e. check that the two AssociationIdentityForAssociationSetMapping objects have the same
        ///     AssociationTable and that all AssociationEndIdentity's in this.Ends are covered by
        ///     AssociationEndIdentity's in other.Ends (for definition of "covering" see
        ///     method AssociationEndIdentity.IsCoveredBy(AssociationEndIdentity))
        /// </summary>
        internal bool IsCoveredBy(AssociationIdentityForAssociationSetMapping other)
        {
            if (false == AssociationTable.Equals(other.AssociationTable))
            {
                return(false);
            }

            foreach (var thisEndId in Ends)
            {
                var foundCoveringEndId = false;
                foreach (var otherEndId in other.Ends)
                {
                    // check whether thisEndId is covered by otherEndId
                    if (thisEndId.IsCoveredBy(otherEndId))
                    {
                        // have found an AssociationEndIdentity in other.Ends which covers thisEndId
                        foundCoveringEndId = true;
                        break;
                    }
                }

                if (false == foundCoveringEndId)
                {
                    // no covering AssociationEndIdentity was found for thisEndId in other.Ends
                    return(false);
                }
            }

            // all AssociationEndIdentity's in this.Ends were covered by an AssociationEndIdentity in other.Ends
            return(true);
        }
Ejemplo n.º 2
0
        public override bool Equals(object obj)
        {
            var objAsAssocIdentity = obj as AssociationIdentityForAssociationSetMapping;

            if (null == objAsAssocIdentity)
            {
                return(false);
            }

            if (!AssociationTable.Equals(objAsAssocIdentity.AssociationTable))
            {
                return(false);
            }

            // see if both ends match
            var thisEndCount = EndCount;

            if (thisEndCount != objAsAssocIdentity.EndCount)
            {
                return(false);
            }
            else if (thisEndCount == 2)
            {
                if (_ends[0].Equals(objAsAssocIdentity._ends[0]) &&
                    _ends[1].Equals(objAsAssocIdentity._ends[1]))
                {
                    return(true);
                }
                else if (_ends[0].Equals(objAsAssocIdentity._ends[1]) &&
                         _ends[1].Equals(objAsAssocIdentity._ends[0]))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (thisEndCount == 1)
            {
                if (_ends[0].Equals(objAsAssocIdentity._ends[0]))
                {
                    return(true);
                }
            }
            else if (thisEndCount == 0)
            {
                return(true);
            }
            else
            {
                Debug.Assert(_ends[1] == null, "unexpected end count number " + thisEndCount + " for " + TraceString());
                return(false);
            }

            return(true);
        }