コード例 #1
0
        // remove entries whose key (CVS) has been GC'd, and whose collection
        // view is no longer in use.  Return true if anything got removed,
        // or if there are no entries left
        internal bool Purge()
        {
            ArrayList al = new ArrayList();

            foreach (DictionaryEntry de in this)
            {
                WeakRefKey key = (WeakRefKey)de.Key;
                if (key.Target == null)
                {
                    ViewRecord     vr = (ViewRecord)de.Value;
                    CollectionView cv = vr.View as CollectionView;

                    if (cv != null)
                    {
                        if (!cv.IsInUse)
                        {
                            // tell the corresponding CollectionView to detach
                            cv.DetachFromSourceCollection();
                            al.Add(key);    // mark this entry for removal
                        }
                    }
                    else
                    {
                        al.Add(key);
                    }
                }
            }

            for (int k = 0; k < al.Count; ++k)
            {
                this.Remove(al[k]);
            }

            return(al.Count > 0 || this.Count == 0);
        }
コード例 #2
0
        // Token: 0x060076E5 RID: 30437 RVA: 0x0021F950 File Offset: 0x0021DB50
        internal bool Purge()
        {
            ArrayList arrayList = new ArrayList();

            foreach (object obj in this)
            {
                DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
                WeakRefKey      weakRefKey      = (WeakRefKey)dictionaryEntry.Key;
                if (weakRefKey.Target == null)
                {
                    ViewRecord     viewRecord     = (ViewRecord)dictionaryEntry.Value;
                    CollectionView collectionView = viewRecord.View as CollectionView;
                    if (collectionView != null)
                    {
                        if (!collectionView.IsInUse)
                        {
                            collectionView.DetachFromSourceCollection();
                            arrayList.Add(weakRefKey);
                        }
                    }
                    else
                    {
                        arrayList.Add(weakRefKey);
                    }
                }
            }
            for (int i = 0; i < arrayList.Count; i++)
            {
                base.Remove(arrayList[i]);
            }
            return(arrayList.Count > 0 || base.Count == 0);
        }