bool ICollection <KeyValuePair <TKey, TValue> > .Contains(KeyValuePair <TKey, TValue> item) { this.op(); var hashedKey = new HashedWeakReference <TKey>(item.Key, this.keyEqualityComparer); return(this.data.Contains(new KeyValuePair <HashedWeakReference <TKey>, TValue>(hashedKey, item.Value))); }
public void Add(TKey key, TValue value) { this.op(); var hashedKey = new HashedWeakReference <TKey>(key, this.keyEqualityComparer); this.data.Add(hashedKey, value); }
public bool Remove(TKey key) { this.op(); var hashedKey = new HashedWeakReference <TKey>(key, this.keyEqualityComparer); return(this.data.Remove(hashedKey)); }
bool ICollection <KeyValuePair <TKey, TValue> > .Remove(KeyValuePair <TKey, TValue> item) { this.op(); var hashedKey = new HashedWeakReference <TKey>(item.Key, this.keyEqualityComparer); var mappedPair = new KeyValuePair <HashedWeakReference <TKey>, TValue>(hashedKey, item.Value); return(((IDictionary <HashedWeakReference <TKey>, TValue>) this.data).Remove(mappedPair)); }
public bool Equals(HashedWeakReference <T> ref1, HashedWeakReference <T> ref2) { bool target1Exists = ref1.reference.TryGetTarget(out T value1); bool target2Exists = ref2.reference.TryGetTarget(out T value2); if (!target1Exists && !target2Exists) { return(true); } return(target1Exists && target2Exists && this.equalityComparer.Equals(value1, value2)); }
public TValue this[TKey key] { [DebuggerHidden] get { this.op(); if (this.TryGetValue(key, out TValue result)) { return(result); } else { throw new KeyNotFoundException("The object with the specified key does not exist"); } } [DebuggerHidden] set { this.op(); var hashedKey = new HashedWeakReference <TKey>(key, this.keyEqualityComparer); data[hashedKey] = value; } }
internal bool TryGetValue(HashedWeakReference <TKey> key, out TValue value) { this.op(); return(this.data.TryGetValue(key, out value)); }
public bool TryGetValue(TKey key, out TValue value) { var hashedKey = new HashedWeakReference <TKey>(key, this.keyEqualityComparer); return(this.TryGetValue(hashedKey, out value)); }
public int GetHashCode(HashedWeakReference <T> obj) { return(obj.hashCode); }