System.ComponentModel.TypeDescriptor.RemoveAssociation C# (CSharp) Method

RemoveAssociation() private method

private RemoveAssociation ( object primary, object secondary ) : void
primary object
secondary object
return void
        public static void RemoveAssociation(object primary, object secondary)
        {
            if (primary == null)
            {
                throw new ArgumentNullException(nameof(primary));
            }

            if (secondary == null)
            {
                throw new ArgumentNullException(nameof(secondary));
            }

            Hashtable assocTable = s_associationTable;
            if (assocTable != null)
            {
                IList associations = (IList)assocTable[primary];
                if (associations != null)
                {
                    lock (associations)
                    {
                        for (int idx = associations.Count - 1; idx >= 0; idx--)
                        {
                            // Look for an associated object that has a type that
                            // matches the given type.
                            //
                            WeakReference weakRef = (WeakReference)associations[idx];
                            object secondaryItem = weakRef.Target;
                            if (secondaryItem == null || secondaryItem == secondary)
                            {
                                associations.RemoveAt(idx);
                            }
                        }
                    }
                }
            }
        }