예제 #1
0
        public override void Dispose()
        {
            Texture2D texture;

            this.texture.TryGetTarget(out texture);
            if (texture != null && !texture.IsDisposed)
            {
                texture.Dispose();
            }
        }
예제 #2
0
        /// <summary>
        /// Removes a weak reference to an object from the collection. Does not cause a purge.
        /// </summary>
        /// <param name="item">The object to remove a weak reference to.</param>
        /// <returns>True if the object was found and removed; false if the object was not found.</returns>
        public bool Remove(T item)
        {
            for (int i = 0; i != this.list.Count; ++i)
            {
                WeakReference <T> weakReference = this.list[i];
                T weakDelegate = weakReference.Target;
                if (weakDelegate == item)
                {
                    this.list.RemoveAt(i);
                    weakReference.Dispose();
                    return(true);
                }
            }

            return(false);
        }