コード例 #1
0
 // Token: 0x06006576 RID: 25974 RVA: 0x001C7285 File Offset: 0x001C5485
 private void WrapKey(ref object key)
 {
     if (key != null && !key.GetType().IsValueType)
     {
         key = new WeakObjectHashtable.EqualityWeakReference(key);
     }
 }
コード例 #2
0
 // Token: 0x06006577 RID: 25975 RVA: 0x001C72A4 File Offset: 0x001C54A4
 public object UnwrapKey(object key)
 {
     WeakObjectHashtable.EqualityWeakReference equalityWeakReference = key as WeakObjectHashtable.EqualityWeakReference;
     if (equalityWeakReference == null)
     {
         return(key);
     }
     return(equalityWeakReference.Target);
 }
コード例 #3
0
        // Token: 0x06006578 RID: 25976 RVA: 0x001C72C4 File Offset: 0x001C54C4
        private void ScavengeKeys()
        {
            int count = this.Count;

            if (count == 0)
            {
                return;
            }
            if (this._lastHashCount == 0)
            {
                this._lastHashCount = count;
                return;
            }
            long totalMemory = GC.GetTotalMemory(false);

            if (this._lastGlobalMem == 0L)
            {
                this._lastGlobalMem = totalMemory;
                return;
            }
            long num  = totalMemory - this._lastGlobalMem;
            long num2 = (long)(count - this._lastHashCount);

            if (num < 0L && num2 >= 0L)
            {
                ArrayList arrayList = null;
                foreach (object obj in this.Keys)
                {
                    WeakObjectHashtable.EqualityWeakReference equalityWeakReference = obj as WeakObjectHashtable.EqualityWeakReference;
                    if (equalityWeakReference != null && !equalityWeakReference.IsAlive)
                    {
                        if (arrayList == null)
                        {
                            arrayList = new ArrayList();
                        }
                        arrayList.Add(equalityWeakReference);
                    }
                }
                if (arrayList != null)
                {
                    foreach (object key in arrayList)
                    {
                        this.Remove(key);
                    }
                }
            }
            this._lastGlobalMem = totalMemory;
            this._lastHashCount = count;
        }