/// <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(); }