private ProcessorResult ProcessPodcastsElements(XmlReader reader) { var result = ProcessorResult.Processed; var elementName = reader.LocalName; switch (elementName) { case "global": XmlSerializationHelper.ProcessElement(reader, "global", ProcessGlobalElements); break; case "podcast": var newPodcast = new PodcastInfo(this); newPodcast.ReadXml(reader); Podcasts.Add(newPodcast); break; default: result = ProcessorResult.Ignored; break; } return(result); }
public async Task ExecuteGetPodcastsCommand() { if (IsBusy) { return; } try { IsBusy = true; var client = new HttpClient(); // Request from server podcast xml var podcastString = await client.GetStringAsync(PodcastUrl); // Parse Xml into data model and load into list var casts = ParseXml(podcastString); foreach (var cast in casts) { Podcasts.Add(cast); FilteredPodcasts.Add(cast); } } catch (Exception ex) { Debug.WriteLine("Unable to get podcasts: " + ex); } finally { IsBusy = false; } }
private void SerachPodcast() { Podcasts.Add(new Podcast() { Name = "Podcast Name", Description = "Podcast Description usually few lines with all kind of stuff going on there pretty cool stuff advertisment etc...", LogoUrl = new Uri("http://is1.mzstatic.com/image/thumb/Music1/v4/80/19/99/8019999e-738b-530e-8de4-2e970048bd02/source/100x100bb.jpg"), PodcastId = 1, RssFeed = new Uri("http://feeds.wnyc.org/radiolab"), }); }
protected override void GivenThat() { Playlist = mocks.DynamicMock <IPlaylist>(); base.GivenThat(); Podcasts.Clear(); Podcasts.Add(new PodcastInfo(ControlFile) { Folder = "Hanselminutes" }); Podcasts.Add(new PodcastInfo(ControlFile) { Folder = "This Developers Life" }); Podcasts[0].Pattern.Value = "*.mp3"; Podcasts[1].Pattern.Value = "*.wma"; var podcastFiles1 = new List <IFileInfo> { GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>() }; podcastFiles1[0].Stub(f => f.FullName).Return(@"c:\destination\Hanselminutes\001.mp3"); podcastFiles1[1].Stub(f => f.FullName).Return(@"c:\destination\Hanselminutes\002.mp3"); var podcastFiles2 = new List <IFileInfo> { GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>() }; // add them so they need sorting podcastFiles2[0].Stub(f => f.FullName).Return(@"c:\destination\This Developers Life\997.wma"); podcastFiles2[1].Stub(f => f.FullName).Return(@"c:\destination\This Developers Life\999.wma"); podcastFiles2[2].Stub(f => f.FullName).Return(@"c:\destination\This Developers Life\998.wma"); Finder.Stub(f => f.GetFiles(@"c:\destination\Hanselminutes", "*.mp3")) .Return(podcastFiles1); Finder.Stub(f => f.GetFiles(@"c:\destination\This Developers Life", "*.wma")) .Return(podcastFiles2); using (mocks.Ordered()) { Playlist.Expect(x => x.AddTrack(@".||Hanselminutes||001.mp3")).Return(true); Playlist.Expect(x => x.AddTrack(@".||Hanselminutes||002.mp3")).Return(true); Playlist.Expect(x => x.AddTrack(@".||This Developers Life||997.wma")).Return(true); Playlist.Expect(x => x.AddTrack(@".||This Developers Life||998.wma")).Return(true); Playlist.Expect(x => x.AddTrack(@".||This Developers Life||999.wma")).Return(true); } Playlist.Replay(); }
private void ExecuteAddPodcastCommand(object parameter) { var dataObject = parameter as IDataObject; var newPodcast = (dataObject != null) ? CreateNewPodcast(_dataObjectUriExtractor.GetUri(dataObject)) : CreateNewPodcast(_clipboardService.GetText()); var newPodcastViewModel = new PodcastViewModel(newPodcast); if (EditPodcast(newPodcastViewModel)) { Podcasts.Add(newPodcastViewModel); } }
private void UpdatePodcasts(NotifyCollectionChangedEventArgs e) { CoreDispatcher dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; UIThread.Dispatch(() => { if (e == null) { Podcasts.Clear(); Podcasts.AddAll(Data.Podcasts.Select((podcast) => new PodcastSummaryViewModel(podcast, ServiceContext))); return; } if (e.Action == NotifyCollectionChangedAction.Add) { foreach (var item in e.NewItems) { Podcast podcast = item as Podcast; if (podcast != null) { Podcasts.Add(new PodcastSummaryViewModel(podcast, ServiceContext)); } else { foreach (Podcast podcastItem in (IEnumerable <Podcast>)item) { Podcasts.Add(new PodcastSummaryViewModel(podcastItem, ServiceContext)); } } } return; } if (e.Action == NotifyCollectionChangedAction.Remove) { foreach (Podcast podcast in e.OldItems) { Podcasts.RemoveFirst((podcastViewModel) => podcastViewModel.Data.Id == podcast.Id); } } }); }
private void LoadPodcasts() { var maxItems = 5; // Min:1 - max:200 var country = "nl"; // Two-letter country code (ISO 3166-1 alpha-2) var finder = new iTunesPodcastFinder.PodcastFinder(); var results = finder.SearchPodcastsAsync("microsoft", maxItems); foreach (var item in results.Result) { Podcasts.Add( new Podcast { Title = item.Name, Description = item.Summary, Url = item.FeedUrl, ImageUrl = item.ArtWork, }); } }
public void SubscribeToPodcast(string link) { IsLoading = true; try { rss Rss; try { Rss = _deserialisedRssProvider.Deserialise(link); } catch (Exception e) { DisplayError(e.Message); return; } Podcast podcast = new Podcast { Title = Rss.channel.title, Url = link, }; if (Podcasts.Contains(podcast)) { DisplayError("Already subscribed to podcast"); return; //todo highlight or jump to/display } Podcasts.Add(podcast); SaveSubscribedPodcasts(); } finally { IsLoading = false; } }
protected override void GivenThat() { base.GivenThat(); Podcasts.Clear(); Podcasts.Add(new PodcastInfo(ControlFile) { Folder = "Hanselminutes" }); Podcasts.Add(new PodcastInfo(ControlFile) { Folder = "This Developers Life" }); Podcasts[0].Pattern.Value = "*.mp3"; Podcasts[1].Pattern.Value = "*.wma"; var podcastFiles1 = new List <IFileInfo> { GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>() }; podcastFiles1[0].Stub(f => f.FullName).Return(@"c:\destination\Hanselminutes\001.mp3"); podcastFiles1[1].Stub(f => f.FullName).Return(@"c:\destination\Hanselminutes\002.mp3"); var podcastFiles2 = new List <IFileInfo> { GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>(), GenerateMock <IFileInfo>() }; podcastFiles2[0].Stub(f => f.FullName).Return(@"c:\destination\This Developers Life\997.wma"); podcastFiles2[1].Stub(f => f.FullName).Return(@"c:\destination\This Developers Life\998.wma"); podcastFiles2[2].Stub(f => f.FullName).Return(@"c:\destination\This Developers Life\999.wma"); Finder.Stub(f => f.GetFiles(@"c:\destination\Hanselminutes", "*.mp3")) .Return(podcastFiles1); Finder.Stub(f => f.GetFiles(@"c:\destination\This Developers Life", "*.wma")) .Return(podcastFiles2); }
public Podcast InsertPodcast(Podcast podcast) { Podcasts.Add(podcast); this.SaveChanges(); return(podcast); }