// Token: 0x06007712 RID: 30482 RVA: 0x002205B8 File Offset: 0x0021E7B8
 private void AddListener(object source, PropertyDescriptor pd, IWeakEventListener listener, EventHandler <ValueChangedEventArgs> handler)
 {
     using (base.WriteLock)
     {
         HybridDictionary hybridDictionary = (HybridDictionary) base[source];
         if (hybridDictionary == null)
         {
             hybridDictionary = new HybridDictionary();
             base[source]     = hybridDictionary;
         }
         ValueChangedEventManager.ValueChangedRecord valueChangedRecord = (ValueChangedEventManager.ValueChangedRecord)hybridDictionary[pd];
         if (valueChangedRecord == null)
         {
             valueChangedRecord   = new ValueChangedEventManager.ValueChangedRecord(this, source, pd);
             hybridDictionary[pd] = valueChangedRecord;
         }
         valueChangedRecord.Add(listener, handler);
         base.ScheduleCleanup();
     }
 }
 // Token: 0x06007713 RID: 30483 RVA: 0x00220638 File Offset: 0x0021E838
 private void RemoveListener(object source, PropertyDescriptor pd, IWeakEventListener listener, EventHandler <ValueChangedEventArgs> handler)
 {
     using (base.WriteLock)
     {
         HybridDictionary hybridDictionary = (HybridDictionary) base[source];
         if (hybridDictionary != null)
         {
             ValueChangedEventManager.ValueChangedRecord valueChangedRecord = (ValueChangedEventManager.ValueChangedRecord)hybridDictionary[pd];
             if (valueChangedRecord != null)
             {
                 valueChangedRecord.Remove(listener, handler);
                 if (valueChangedRecord.IsEmpty)
                 {
                     hybridDictionary.Remove(pd);
                 }
             }
             if (hybridDictionary.Count == 0)
             {
                 base.Remove(source);
             }
         }
     }
 }
        // Token: 0x0600770C RID: 30476 RVA: 0x002203C0 File Offset: 0x0021E5C0
        protected override bool Purge(object source, object data, bool purgeAll)
        {
            bool             result           = false;
            HybridDictionary hybridDictionary = (HybridDictionary)data;

            if (!BaseAppContextSwitches.EnableWeakEventMemoryImprovements)
            {
                ICollection          keys  = hybridDictionary.Keys;
                PropertyDescriptor[] array = new PropertyDescriptor[keys.Count];
                keys.CopyTo(array, 0);
                for (int i = array.Length - 1; i >= 0; i--)
                {
                    bool flag = purgeAll || source == null;
                    ValueChangedEventManager.ValueChangedRecord valueChangedRecord = (ValueChangedEventManager.ValueChangedRecord)hybridDictionary[array[i]];
                    if (!flag)
                    {
                        if (valueChangedRecord.Purge())
                        {
                            result = true;
                        }
                        flag = valueChangedRecord.IsEmpty;
                    }
                    if (flag)
                    {
                        valueChangedRecord.StopListening();
                        if (!purgeAll)
                        {
                            hybridDictionary.Remove(array[i]);
                        }
                    }
                }
            }
            else
            {
                IDictionaryEnumerator enumerator = hybridDictionary.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    bool flag2 = purgeAll || source == null;
                    ValueChangedEventManager.ValueChangedRecord valueChangedRecord2 = (ValueChangedEventManager.ValueChangedRecord)enumerator.Value;
                    if (!flag2)
                    {
                        if (valueChangedRecord2.Purge())
                        {
                            result = true;
                        }
                        flag2 = valueChangedRecord2.IsEmpty;
                    }
                    if (flag2)
                    {
                        valueChangedRecord2.StopListening();
                        if (!purgeAll)
                        {
                            this._toRemove.Add((PropertyDescriptor)enumerator.Key);
                        }
                    }
                }
                if (this._toRemove.Count > 0)
                {
                    foreach (PropertyDescriptor key in this._toRemove)
                    {
                        hybridDictionary.Remove(key);
                    }
                    this._toRemove.Clear();
                    this._toRemove.TrimExcess();
                }
            }
            if (hybridDictionary.Count == 0)
            {
                result = true;
                if (source != null)
                {
                    base.Remove(source);
                }
            }
            return(result);
        }