// ******************** // Methods public void Add(TKey key, TValue value) { if (key == null) { throw new ArgumentNullException("key"); } var weakKey = new WeakKeyReference <TKey>(key, _comparer); _dict.Add(weakKey, value); }
// ******************** // PROPS public TValue this[TKey key] { get { try { return(_dict[key]); } catch { throw new KeyNotFoundException(); } } set { if (key == null) { throw new ArgumentNullException("key"); } var weakKey = new WeakKeyReference <TKey>(key, _comparer); _dict[weakKey] = value; } }