public int GetHashCode(object obj) { WeakKeyReference <T> weakKey = obj as WeakKeyReference <T>; if (weakKey != null) { return(weakKey.HashCode); } return(this.comparer.GetHashCode((T)obj)); }
public override void Add(TKey key, TValue value) { if (key == null) { throw new ArgumentNullException("key"); } WeakReference <TKey> weakKey = new WeakKeyReference <TKey>(key, this.comparer); this.dictionary.Add(weakKey, value); }
private static T GetTarget(object obj, out bool isDead) { WeakKeyReference <T> wref = obj as WeakKeyReference <T>; T target; if (wref != null) { target = wref.Target; isDead = !wref.IsAlive; } else { target = (T)obj; isDead = false; } return(target); }
protected override void SetValue(TKey key, TValue value) { WeakReference <TKey> weakKey = new WeakKeyReference <TKey>(key, this.comparer); this.dictionary[weakKey] = value; }