public FeedItemLayoutData(CanvasDevice device, FeedItem feedItem, float fRequestedWidth) { FeedDataTitleLayout = new CanvasTextLayout(device, feedItem.FeedDataTitle, Statics.DefaultFont, fRequestedWidth, 20); PublicationDateLayout = new CanvasTextLayout(device, feedItem.PublicationDate.ToString("MM/dd/yy"), Statics.DefaultFont, fRequestedWidth, 20); // MMMM dd, yyyy - h:mm TitleLayout = new CanvasTextLayout(device, feedItem.Title, Statics.DefaultFont, fRequestedWidth, 20); AuthorLayout = new CanvasTextLayout(device, feedItem.Author, Statics.DefaultFont, fRequestedWidth, 20); if (feedItem.Title != feedItem.Content) { ContentLayout = new CanvasTextLayout(device, feedItem.Content, Statics.DefaultFont, fRequestedWidth, 20); } LinkLayout = new CanvasTextLayout(device, feedItem.Link.ToString(), Statics.DefaultFont, fRequestedWidth, 20); }
public void SetFeedItem(CanvasDevice device, FeedItem feedItem) { if (feedItem == null) { return; } FeedItem = feedItem; FeedItemLayoutData = new FeedItemLayoutData(device, feedItem, Width - Padding * 2); }
private static async Task<FeedData> GetFeedAsync(string strUri) { SyndicationClient client = new SyndicationClient(); Uri feedUri = new Uri(strUri); try { SyndicationFeed feed = await client.RetrieveFeedAsync(feedUri); FeedData feedData = new FeedData(); if (feed.Title != null && feed.Title.Text != null) { feedData.Title = feed.Title.Text; } if (feed.Subtitle != null && feed.Subtitle.Text != null) { feedData.Description = feed.Subtitle.Text; } if (feed.Items != null && feed.Items.Count > 0) { feedData.PublicationDate = feed.Items[0].PublishedDate.DateTime; foreach (SyndicationItem item in feed.Items) { string title = string.Empty; DateTime date = DateTime.Now; string author = string.Empty; string content = string.Empty; Uri link = null; if (item.Title != null && item.Title.Text != null) { title = Statics.Sanitize(item.Title.Text); } if (item.PublishedDate != null) { date = item.PublishedDate.DateTime; } if (item.Authors != null && item.Authors.Count > 0) { author = item.Authors[0].Name; } switch (feed.SourceFormat) { case SyndicationFormat.Atom10: if (item.Content != null && item.Content.Text != null) { content = Statics.Sanitize(item.Content.Text); } if (item.Id != null) { // not sure about this link = new Uri(item.Id); } break; case SyndicationFormat.Rss20: if (item.Summary != null && item.Summary.Text != null) { content = Statics.Sanitize(item.Summary.Text); } if (item.Links != null && item.Links.Count > 0) { link = item.Links[0].Uri; } break; default: throw new Exception(); } FeedItem feedItem = new FeedItem(feedData.Title, title, author, content, date, link); feedData.Items.Add(feedItem); } } return feedData; } catch (Exception e) { return null; } }
public void RecycleFeedItemData() { FeedDataSource.Recycle(FeedItem); FeedItem = null; }
public static void Recycle(FeedItem fi) { if (fi != null) { FeedItems.Add(fi); } }