public int RemovePodcasts(ICollection podcasts, bool update) { if (podcasts == null) { throw new ArgumentNullException("podcasts"); } ArrayList removed_podcasts = new ArrayList(); lock (PodcastSync) { foreach (PodcastInfo pi in podcasts) { if (pi != null) { try { if (RemovePodcastFromLibrary(pi, false)) { removed_podcasts.Add(pi); } } catch { continue; } } } if (update && (removed_podcasts.Count > 0)) { PodcastEventArgs args; if (removed_podcasts.Count == 1) { args = new PodcastEventArgs(removed_podcasts[0] as PodcastInfo); } else { args = new PodcastEventArgs(removed_podcasts); } try { UpdateParentFeeds(removed_podcasts); EmitPodcastRemoved(args); } finally { PodcastDBManager.Deactivate(removed_podcasts); } } } return(removed_podcasts.Count); }
private bool RemovePodcastFromLibrary(PodcastInfo pi, bool commit_podcast) { if (pi == null) { throw new ArgumentNullException("pi"); } if (pi.IsQueued) { return(false); } podcasts.Remove(pi.Key); if (pi.Track != null) { ThreadAssist.ProxyToMain(delegate { RemoveTrack(pi.Track, true); }); } if (!pi.IsActive) { return(true); } else { pi.IsActive = false; } if (commit_podcast) { PodcastDBManager.Deactivate(pi); } return(true); }