Inheritance: ICloneable
Ejemplo n.º 1
0
 public object Clone()
 {
     var copy = new FeedItem
                    {
                        Date = this.Date,
                        Description = this.Description,
                        Link = this.Link,
                        Title = this.Title,
                        Updated = false
                    };
     return copy;
 }
Ejemplo n.º 2
0
        private static FeedItem GetItemFromFeedEntry(IXmlNamespaceResolver xmlNamespaceManager,
            XPathNodeIterator xPathNodeIterator)
        {
            var item = new FeedItem();
            if (xPathNodeIterator.Current != null)
            {
                var subnav = xPathNodeIterator.Current.CreateNavigator();

                var titlenode = subnav.SelectSingleNode("rss:title", xmlNamespaceManager);
                item.Title = titlenode == null ? "(untitled)" : WebUtility.HtmlDecode(titlenode.ToString()).Trim();

                var linknode = subnav.SelectSingleNode("rss:link", xmlNamespaceManager);
                if (linknode != null)
                {
                    Uri result;
                    if (Uri.TryCreate(linknode.ToString(), UriKind.Absolute, out result))
                    {
                        item.Link = result;
                    }
                }
                var descriptionnode = subnav.SelectSingleNode("rss:description", xmlNamespaceManager);
                if (descriptionnode != null)
                {
                    item.Description = descriptionnode.ToString();
                }

                var tempnav = subnav.SelectSingleNode("dc:date", xmlNamespaceManager);
                if (tempnav != null)
                {
                    DateTime gdt;
                    var res = DateTime.TryParse(tempnav.ToString(), out gdt);
                    if (res)
                    {
                        item.Date = gdt;
                    }
                }

            }
            return item;
        }
Ejemplo n.º 3
0
        private static FeedItem GetItemFromFeedEntry(XPathNodeIterator xPathNodeIterator)
        {
            var item = new FeedItem();
            if (xPathNodeIterator.Current != null)
            {
                var pathNavigator = xPathNodeIterator.Current.CreateNavigator();

                var titlenode = pathNavigator.SelectSingleNode("title");
                item.Title = titlenode == null ? "(untitled)" : WebUtility.HtmlDecode(titlenode.ToString()).Trim();

                var linknode = pathNavigator.SelectSingleNode("link");
                if (linknode != null)
                {
                    Uri result;
                    if (Uri.TryCreate(linknode.ToString(), UriKind.Absolute, out result))
                    {
                        item.Link = result;
                    }
                }

                try
                {
                    var tempnav = pathNavigator.SelectSingleNode("pubDate");
                    if (tempnav != null)
                    {
                        DateTime gdt;
                        var res = DateTime.TryParse(tempnav.ToString(), out gdt);
                        if (res)
                        {
                            item.Date = gdt;
                        }
                    }
                }
                catch (FormatException)
                {
                }
            }
            return item;
        }
Ejemplo n.º 4
0
        private static FeedItem GetItemFromFeedEntry(XPathNodeIterator xPathNodeIterator, IXmlNamespaceResolver xmlNamespaceManager)
        {
            var item = new FeedItem();

            if (xPathNodeIterator.Current != null)
            {
                var subnav = xPathNodeIterator.Current.CreateNavigator();
                var textnode = subnav.SelectSingleNode("atom:title/text()", xmlNamespaceManager);
                item.Title = textnode == null ? "(untitled)" : WebUtility.HtmlDecode(textnode.ToString()).Trim();
                var linkiterator = subnav.Select("atom:link", xmlNamespaceManager);
                while (linkiterator.MoveNext() && item.Link == null)
                {
                    var linknav = linkiterator.Current;
                    if (linknav != null)
                    {
                        if (!linknav.HasAttributes) continue;
                        var rel = linknav.GetAttribute("rel", "");
                        if (rel.Equals("alternate"))
                        {
                            item.Link = new Uri(linknav.GetAttribute("href", ""));
                        }
                    }
                }
                // If no link with rel = 'alternate' in the entry, just pick the first link
                if (item.Link == null)
                {
                    var linknav = subnav.SelectSingleNode("atom:link", xmlNamespaceManager);
                    if (linknav != null)
                    {
                        Uri result;
                        if (Uri.TryCreate(linknav.GetAttribute("href", ""), UriKind.Absolute, out result))
                        {
                            item.Link = result;
                        }
                    }
                }
                var updatednav = subnav.SelectSingleNode("atom:updated/text()", xmlNamespaceManager);
                if (updatednav != null)
                {
                    DateTime gdt;
                    var res = DateTime.TryParse(updatednav.ToString(), out gdt);
                    if (res)
                    {
                        item.Date = gdt;
                    }
                }
            }
            return item;
        }