コード例 #1
0
        public bool Equals(ref WeakKey <E> key1, bool key1IsWeak, ref WeakKey <E> key2, bool key2IsWeak)
        {
            var obj1 = key1IsWeak ? ((WeakReference)key1._elementReference).Target : key1._elementReference;
            var obj2 = key2IsWeak ? ((WeakReference)key2._elementReference).Target : key2._elementReference;

            return
                (obj1 == null ? obj2 == null && object.ReferenceEquals(key1._elementReference, key2._elementReference) :
                 obj2 == null ? false :
                 object.ReferenceEquals(obj1, obj2) ? true :
                 _equalityComparer.Equals((E)obj1, (E)obj2));
        }
コード例 #2
0
 public int GetHashCode(ref WeakKey <E> obj, bool objIsWeak)
 {
     return(_equalityComparer.GetHashCode((E)(objIsWeak ? ((WeakReference)obj._elementReference).Target : obj._elementReference)));
 }