/// <summary>
        /// <see cref="DvMediaContainer.RemoveObject"/>
        /// and <see cref="DvMediaContainer.RemoveObjects"/>
        /// call this method before removing it from its child list.
        /// This will automatically remove items that refer to this item
        /// from their respective parents.
        /// </summary>
        public void NotifyPendingDelete()
        {
            lock (this.m_LockReferences)
            {
                this.m_Deleting = true;

                ArrayList removeThese = new ArrayList();

                if (m_ReferringItems != null)
                {
                    //foreach (WeakReference wr in this.m_ReferringItems)
                    foreach (IDvItem referringItem in this.m_ReferringItems)
                    {
                        // force a strong reference of the target before checking it's alive

                        //IDvItem referringItem = (IDvItem) wr.Target;
                        //if (wr.IsAlive)
                        //{
                        IDvContainer parent = (IDvContainer)referringItem.Parent;

                        if (parent != null)
                        {
                            parent.RemoveObject(referringItem);
                        }
                        else
                        {
                            //removeThese.Add(wr);
                            removeThese.Add(referringItem);
                        }
                        //}
                        //else
                        //{
                        //	removeThese.Add(wr);
                        //}
                    }

                    //foreach (WeakReference wr in removeThese)
                    foreach (IDvItem referringItem in removeThese)
                    {
                        //this.m_ReferringItems.Remove(wr);
                        this.m_ReferringItems.Remove(referringItem);
                    }
                }

                this.m_ReferringItems = null;
                this.m_RefItem        = null;
            }
        }
        /// <summary>
        /// This removes a container or item object from
        /// the child list. It is used by other
        /// RemoveXXX methods defined in this class
        /// and implements the portion that allows
        /// proper media server eventing.
        /// <para>
        /// Method properly tells items to notify all other
        /// items that reference it that it will be deleted.
        /// </para>
        /// <para>
        /// Method properly tells containers to recursively
        /// remove their child objects, so that descendent
        /// reference items are properly removed.
        /// </para>
        /// </summary>
        /// <param name="removeThis"></param>
        public override void RemoveObject(IUPnPMedia removeThis)
        {
            IDvMedia     dv        = removeThis as IDvMedia;
            IDvItem      item      = removeThis as IDvItem;
            IDvContainer container = removeThis as IDvContainer;

            // Before we go about doing any removal operations,
            // we fire the event to indicate this object is
            // about to be removed.
            ArrayList removeThese = new ArrayList(1);

            removeThese.Add(removeThis);
            if (this.OnChildrenToRemove != null)
            {
                this.OnChildrenToRemove(this, removeThese);
            }

            if (item != null)
            {
                // Notify any and all referring items that
                // this object is about to be removed
                // from its parent.
                item.NotifyPendingDelete();
            }
            else if (container != null)
            {
                // Instruct all child containers to
                // remove their own children.
                IList children = container.CompleteList;
                foreach (IDvMedia child in children)
                {
                    container.RemoveObject(child);
                }
            }

            // go ahead and remove this object
            base.RemoveObject(removeThis);

            // Notify that the child has formerly been
            // removed.
            if (this.OnChildrenRemoved != null)
            {
                this.OnChildrenRemoved(this, removeThese);
            }

            this.NotifyRootOfChange();
        }