public override int CompareTo(NewsItem other) { RssNewsItem otherItem = (RssNewsItem)other; if (string.IsNullOrEmpty(Guid) == false) {// Just compare the Guids, if they are present, since otherwise some // sources republish items and this causes multiplication. return(_guid.CompareTo(otherItem._guid)); } int compare = base.CompareTo(other); if (compare != 0 || other.GetType() != this.GetType()) { return(compare); } compare = _author.CompareTo(otherItem.Author); if (compare != 0) { return(compare); } compare = _comments.CompareTo(otherItem._comments); if (compare != 0) { return(compare); } compare = GeneralHelper.CompareNullable(_guid, otherItem._guid); return(compare); }
/// <summary> /// /// </summary> public NewsItemControl(RssNewsItem newsItem) { InitializeComponent(); NewsItem = newsItem; }
/// <summary> /// Helper. node.ChildNodes[0].InnerText + ">>" + node.Attributes["href"].Value + "; " + Environment.NewLine; /// </summary> /// <param name="node"></param> /// <param name="fetchDate"></param> /// <returns></returns> RssNewsItem CreateNewsItem(HtmlNode node, bool fetchDateAndDetails) { RssNewsItem item = new RssNewsItem(this); item.Author = "Bloomberg"; item.Comments = ""; if (node.ParentNode.Name == "p" && node.ParentNode.ChildNodes[2].Name == "#text") {// Description available in parent. item.Description = GeneralHelper.RepairHTMLString(node.ParentNode.ChildNodes[2].InnerText); item.Description = item.Description.Replace("\n", " "); } else { item.Description = ""; } item.Link = new Uri(BaseAddress + node.Attributes["href"].Value); item.Title = node.ChildNodes[0].InnerText; if (fetchDateAndDetails) { HtmlDocument document = GenerateDocument(item.Link.AbsoluteUri); if (document == null) { return null; } HtmlNodeCollection nodes = document.DocumentNode.SelectNodes("//i"); foreach (HtmlNode iNode in nodes) { string dateTimeInfo = iNode.ChildNodes[0].InnerText; DateTime time = GeneralHelper.ParseDateTimeWithZone(dateTimeInfo.Replace("Last Updated:", "")); item.DateTime = time; } } return item; }