void TwitterStatusInformationCompleted(object sender, DownloadStringCompletedEventArgs e) { LoadEventArgs loadedEventArgs = new LoadEventArgs(); try { var doc = XDocument.Parse(e.Result); foreach (var item in doc.Descendants("status")) { var model = new TwitterStatusModel() { Date = item.Element("created_at").Value.Substring(0, item.Element("created_at").Value.IndexOf('+')), Text = item.Element("text").Value, }; TwitterFeed.Add(model); } loadedEventArgs.IsLoaded = true; loadedEventArgs.Message = ""; } catch (Exception) { loadedEventArgs.IsLoaded = false; loadedEventArgs.Message = "unable to load twitter data"; } finally { OnTwitterLoaded(loadedEventArgs); } TwitterFeed = null; }
void DownloadPodcastInformationCompleted(object sender, DownloadStringCompletedEventArgs e) { LoadEventArgs loadedEventArgs = new LoadEventArgs(); try { var doc = XDocument.Parse(e.Result); var xChannel = doc.Descendants("channel").First(); PodcastInformation.Title = getElementValue(xChannel, "title"); PodcastInformation.Description = getElementValue(xChannel, "description"); PodcastInformation.Copyright = getElementValue(xChannel, "copyright"); PodcastInformation.Rating = getElementValue(xChannel, "rating"); PodcastInformation.WebMaster = getElementValue(xChannel, "webMaster"); PodcastInformation.Link = getElementValue(xChannel, "link"); PodcastInformation.Language = getElementValue(xChannel, "language"); PodcastInformation.ManagingDirector = getElementValue(xChannel, "managingEditor"); PodcastInformation.ImageUrl = Coalesce(Settings.DefaulImage, getElementValue(xChannel, ITUNES + "image", "href")).ToString(); foreach (var item in xChannel.Descendants("item")) { PodcastItemModel pim = new PodcastItemModel() { Title = getElementValue(item, "title").Trim(), Link = getElementValue(item, "link"), Date = RssHelper.ParseRssDate(getElementValue(item, "pubDate")), Description = StripHtmlTags(getElementValue(item, "description")).Trim(), EnclosureUrl = getElementValue(item, "enclosure", "url"), SourceUrl = getElementValue(item, "link"), ImageUrl = Coalesce( ParseImageFromDescription(getElementValue(item, "description")), getElementValue(item, ITUNES + "image", "href"), PodcastInformation.ImageUrl, Settings.DefaulImage ).ToString(), }; // ensure that there is an enclosure. No enclosure == no podcast media :( if (pim.EnclosureUrl.Length == 0) { pim.EnclosureUrl = "no media available"; } // finally, add the item to the collection PodcastInformation.Items.Add(pim); } loadedEventArgs.IsLoaded = true; loadedEventArgs.Message = ""; } catch (Exception ex) { loadedEventArgs.IsLoaded = false; loadedEventArgs.Message = "unable to load data"; } finally { OnPodcastInfoLoaded(loadedEventArgs); } }
protected virtual void OnPodcastInfoLoaded(LoadEventArgs e) { if (InformationLoaded != null) { InformationLoaded(this, e); } }
protected virtual void OnTwitterLoaded(LoadEventArgs e) { if (TwitterLoaded != null) { TwitterLoaded(this, e); } }
void Service_InformationLoaded(object sender, LoadEventArgs e) { PodcastInfoDataStatus = e.Message; }
void Service_TwitterLoaded(object sender, LoadEventArgs e) { TwitterDataStatus = e.Message; }