Ejemplo n.º 1
0
        public void CanRemoveAnObjectThatWasAlreadyAdded()
        {
            object o = new object();
            WeakRefDictionary <object, object> dict = new WeakRefDictionary <object, object>();

            dict.Add("foo", o);
            dict.Remove("foo");
            object unused = dict["foo"];
        }
Ejemplo n.º 2
0
        public void RemovingAKeyOfOneObjectDoesNotAffectOtherKeysForSameObject()
        {
            object o = new object();
            WeakRefDictionary <object, object> dict = new WeakRefDictionary <object, object>();

            dict.Add("foo1", o);
            dict.Add("foo2", o);
            dict.Remove("foo1");

            Assert.AreSame(o, dict["foo2"]);
        }
Ejemplo n.º 3
0
        public void RemovingAKeyDoesNotAffectOtherKeys()
        {
            object o1 = new object();
            object o2 = new object();
            WeakRefDictionary <object, object> dict = new WeakRefDictionary <object, object>();

            dict.Add("foo1", o1);
            dict.Add("foo2", o2);
            dict.Remove("foo1");

            Assert.AreSame(o2, dict["foo2"]);
        }
Ejemplo n.º 4
0
        public void RemovingANonExistantKeyDoesntThrow()
        {
            WeakRefDictionary <object, object> dict = new WeakRefDictionary <object, object>();

            dict.Remove("foo1");
        }
		public void RemovingAKeyOfOneObjectDoesNotAffectOtherKeysForSameObject()
		{
			object o = new object();
			WeakRefDictionary<object, object> dict = new WeakRefDictionary<object, object>();

			dict.Add("foo1", o);
			dict.Add("foo2", o);
			dict.Remove("foo1");

			Assert.AreSame(o, dict["foo2"]);
		}
		public void CanRemoveAnObjectThatWasAlreadyAdded()
		{
			object o = new object();
			WeakRefDictionary<object, object> dict = new WeakRefDictionary<object, object>();

			dict.Add("foo", o);
			dict.Remove("foo");
			object unused = dict["foo"];
		}
		public void RemovingANonExistantKeyDoesntThrow()
		{
			WeakRefDictionary<object, object> dict = new WeakRefDictionary<object, object>();
			dict.Remove("foo1");
		}
		public void RemovingAKeyDoesNotAffectOtherKeys()
		{
			object o1 = new object();
			object o2 = new object();
			WeakRefDictionary<object, object> dict = new WeakRefDictionary<object, object>();

			dict.Add("foo1", o1);
			dict.Add("foo2", o2);
			dict.Remove("foo1");

			Assert.AreSame(o2, dict["foo2"]);
		}
Ejemplo n.º 9
0
 /// <summary>Allows to manually remove an object instance from the manager. A subsequent call to GetObject with the same key will create a new instance.</summary>
 /// <param name="key">The key of the object instance to be removed.</param>
 public void Remove(TKey key)
 {
     _objects.Remove(key);
 }