Example #1
0
        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)));
        }
Example #2
0
        public void Add(TKey key, TValue value)
        {
            this.op();
            var hashedKey = new HashedWeakReference <TKey>(key, this.keyEqualityComparer);

            this.data.Add(hashedKey, value);
        }
Example #3
0
        public bool Remove(TKey key)
        {
            this.op();
            var hashedKey = new HashedWeakReference <TKey>(key, this.keyEqualityComparer);

            return(this.data.Remove(hashedKey));
        }
Example #4
0
        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));
        }
Example #6
0
 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;
     }
 }
Example #7
0
        internal bool TryGetValue(HashedWeakReference <TKey> key, out TValue value)
        {
            this.op();

            return(this.data.TryGetValue(key, out value));
        }
Example #8
0
        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);
 }