public override bool Equals(object obj) { try { RssFeedModel other = (RssFeedModel)obj; return(this.feedName == other.feedName && this.Description == other.Description && this.Link == other.Link); } catch (InvalidCastException e) { return(false); } }
private async Task AddRssFeed(string url) { try { SyndicationClient client = new SyndicationClient(); Uri myUri; if (Uri.TryCreate(url, UriKind.Absolute, out myUri)) { if ((myUri.Scheme == "http" || myUri.Scheme == "https")) { SyndicationFeed feed = await client.RetrieveFeedAsync(new Uri(url)); RssFeedModel feedModel = new RssFeedModel(feed.Title.Text, feed.Subtitle != null ? feed.Subtitle.Text : "", new Uri(url), null); feedModel.ArticleList = new ObservableCollection<RssArticleModel>(feed.Items.Select(f => new RssArticleModel(f.Title.Text, f.Summary != null ? Regex.Replace(Regex.Replace(f.Summary.Text, "\\&.{0,4}\\;", string.Empty), "<.*?>", string.Empty) : "", f.Authors.Select(a => a.NodeValue).FirstOrDefault(), f.ItemUri != null ? f.ItemUri : f.Links.Select(l => l.Uri).FirstOrDefault() ))); if (FeedsList.Contains(feedModel)) { FeedsList.Remove(feedModel); } FeedsList.Add(feedModel); } } } catch (Exception) { InvalidRSSFeedMessageVisibility = Visibility.Visible; } }