Esempio n. 1
0
        public void WeakReferences_Are_Equal()
        {
            var testObject = new object();
            var wRef1      = new WeakReference(testObject);
            var wRef2      = new WeakReference(testObject);
            var comparer   = new WeakReferenceComparer();

            Assert.AreNotEqual(wRef1, wRef2);
            Assert.IsFalse(wRef1.Equals(wRef2));
            Assert.IsFalse(wRef1 == wRef2);

            Assert.IsTrue(comparer.Equals(wRef1, wRef2));
            Assert.IsFalse(comparer.Equals(null, wRef2));
            Assert.IsFalse(comparer.Equals(wRef1, null));
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WeakDictionary{TKey, TValue}"/> class.
        /// </summary>
        public WeakDictionary()
        {
            var comparer = new WeakReferenceComparer <TKey>();

            _inner = new Dictionary <object, WeakReference>(comparer);
        }