예제 #1
0
        /// <summary>
        /// Adds the specified <see cref="WeakReference{T}"/> to this collection.
        /// The <see cref="WeakReference{T}"/> itself is stored using a strong reference.
        /// </summary>
        /// <param name="weakRef">The <see cref="WeakReference{T}"/> to add.</param>
        public void Add(WeakReference <T> weakRef)
        {
            if (weakRef.NullReference())
            {
                throw Exc.Null(nameof(weakRef));
            }

            //// NOTE: we are not checking whether the weak reference is still alive,
            ////       since the assumption is that it was recently created (e.g. by one of our other members).

            this.list.Add(weakRef);
        }