/// <summary>
        /// Compares two sets for equality. Order does not matter.
        /// </summary>
        /// <param name="obj">Other set for comparison</param>
        /// <returns>true if equals</returns>
        public override bool Equals(object obj)
        {
            if (System.Object.ReferenceEquals(this, obj))
            {
                return(true);
            }

            if (!(obj is NamespaceSet))
            {
                return(false);
            }

            NamespaceSet nss = (NamespaceSet)obj;

            if (this.NSSet.Length != nss.NSSet.Length)
            {
                return(false);
            }

            if (this.NSSet.Length == 0)
            {
                return(true);
            }

            if (this.NSSetEqualityCache == null)
            {
                this.NSSetEqualityCache = new HashSet <Namespace>(this.NSSet);
            }

            /* This cunning device only works if you can guarantee that there are no
             * duplicates in the set. For our purposes though, if there are duplicates, and this
             * still returns true, then we can treat the sets as equivalent, so we don't care.
             */
            return(this.NSSetEqualityCache.SetEquals(nss.NSSet));
        }
Beispiel #2
0
        internal NamespaceSet CreateNamespaceSet(Namespace[] nsRefs)
        {
            NamespaceSet set = new NamespaceSet(nsRefs);

            this.nsSetConsts.Add(set);
            return(set);
        }
Beispiel #3
0
        internal Multiname CreateMultiname(Multiname.MultinameKind kind, string name, Namespace ns, NamespaceSet set)
        {
            Multiname mn = new Multiname(kind, name, ns, set);

            this.multinameConsts.Add(mn);
            return(mn);
        }
Beispiel #4
0
 /// <summary>
 /// Adds a set to the code.
 /// </summary>
 /// <param name="set">The set to add.</param>
 public void AddNamespaceSet(NamespaceSet set)
 {
     this.nsSetConsts.Add(set);
 }