Beispiel #1
0
        /// <summary>
        /// Generates an index from <see cref="IEnumerable{BlogEntry}"/>.
        /// </summary>
        /// <param name="repository">The repository.</param>
        /// <param name="entries">The entries.</param>
        /// <param name="topics">The topics.</param>
        /// <param name="useJavaScriptCase">when <c>true</c> use “camel” casing.</param>
        /// <returns></returns>
        /// <exception cref="NullReferenceException">
        /// The expected Blog entries are not here.
        /// or
        /// The expected Blog entries are not here.
        /// </exception>
        /// <exception cref="System.NullReferenceException">The expected Blog entries are not here.
        /// or
        /// The expected Blog entries are not here.
        /// or
        /// The expected Blog topics are not here.</exception>
        public static string GenerateIndex(this IEnumerable <BlogEntry> entries, OpmlDocument topics, bool useJavaScriptCase)
        {
            if (entries == null)
            {
                throw new NullReferenceException("The expected Blog entries are not here.");
            }
            if (!entries.Any())
            {
                throw new NullReferenceException("The expected Blog entries are not here.");
            }

            traceSource?.TraceInformation("Generating Blog Index...");

            var entriesLite = entries.Select(i =>
            {
                var entry = i.ToMemberwiseClone()
                            .WithItemCategory(topics)
                            .WithContentAsExtract();

                traceSource?.TraceVerbose("entry: {0}", entry);

                return(entry);
            });

            var serializerSettings = GetJsonSerializerSettings(useJavaScriptCase);
            var json = JsonConvert.SerializeObject(entriesLite, serializerSettings);

            return(json);
        }
        /// <summary>
        /// Modifies the <see cref="ISyndicationResource"/> to match the data source.
        /// </summary>
        /// <param name="resource">The Outline Processor Markup Language (OPML) <see cref="ISyndicationResource"/> to be filled.</param>
        /// <param name="resourceMetadata">A <see cref="SyndicationResourceMetadata"/> object that represents the meta-data describing the <paramref name="resource"/>.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="resource"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="resourceMetadata"/> is a null reference (Nothing in Visual Basic).</exception>
        private void FillOpmlResource(ISyndicationResource resource, SyndicationResourceMetadata resourceMetadata)
        {
            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(resource, "resource");
            Guard.ArgumentNotNull(resourceMetadata, "resourceMetadata");

            //------------------------------------------------------------
            //	Fill syndication resource using appropriate data adapter
            //------------------------------------------------------------
            OpmlDocument opmlDocument = resource as OpmlDocument;
            Opml20SyndicationResourceAdapter opml20Adapter = new Opml20SyndicationResourceAdapter(this.Navigator, this.Settings);

            if (resourceMetadata.Version == new Version("2.0"))
            {
                opml20Adapter.Fill(opmlDocument);
            }

            if (resourceMetadata.Version == new Version("1.1"))
            {
                opml20Adapter.Fill(opmlDocument);
            }

            if (resourceMetadata.Version == new Version("1.0"))
            {
                opml20Adapter.Fill(opmlDocument);
            }
        }
        /// <summary>
        /// Provides example code for the Load(XmlReader) method
        /// </summary>
        public static void LoadXmlReaderExample()
        {
            #region Load(XmlReader reader)
            OpmlDocument document = new OpmlDocument();

            using (Stream stream = new FileStream("OpmlDocument.xml", FileMode.Open, FileAccess.Read))
            {
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.IgnoreComments   = true;
                settings.IgnoreWhitespace = true;

                using (XmlReader reader = XmlReader.Create(stream, settings))
                {
                    document.Load(reader);

                    foreach (OpmlOutline outline in document.Outlines)
                    {
                        if (outline.IsSubscriptionListOutline)
                        {
                            //  Process outline information
                        }
                    }
                }
            }
            #endregion
        }
Beispiel #4
0
        private void LoadRssFeeds(OpmlDocument opmlDocument)
        {
            IList <OpmlOutline> outlines = opmlDocument.Body.Outlines;

            for (int index = 0; index < outlines.Count; index++)
            {
                if (rssEvents[index] == null)
                {
                    rssEvents[index] = new AutoResetEvent(false);
                }

                ThreadPool.QueueUserWorkItem(new WaitCallback(GetRssFeeds), new OutlineInfo(outlines[index], index));
            }

            if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
            {
                // WaitAll for multiple handles on an STA thread is not supported.
                // ...so wait on each handle individually.
                foreach (WaitHandle waitHandle in rssEvents)
                {
                    WaitHandle.WaitAny(new WaitHandle[] { waitHandle });
                }
            }
            else
            {
                WaitHandle.WaitAll(rssEvents);
            }
        }
Beispiel #5
0
        public void OpmlDocumentBodyTest()
        {
            OpmlDocument target = RssToolkitUnitTest.Utility.RssUtility.GetOpmlDocumentFromXml();

            Assert.IsTrue(target.Body.Outlines.Count > 0, "RssToolkit.Opml.OpmlDocument.Body was not set correctly.");
            Assert.AreEqual("BBC News | News Front Page | UK Edition", target.Body.Outlines[0].Text, "RssToolkit.Opml.OpmlDocument.Body was not set correctly.");
            Assert.AreEqual("CNET News.com", target.Body.Outlines[1].Text, "RssToolkit.Opml.OpmlDocument.Body was not set correctly.");
        }
Beispiel #6
0
        /// <summary>
        /// Provides example code for the LoadAsync(Uri, Object) method
        /// </summary>
        public static void LoadAsyncExample()
        {
            OpmlDocument document = new OpmlDocument();

            document.Loaded += new EventHandler <SyndicationResourceLoadedEventArgs>(ResourceLoadedCallback);

            document.LoadAsync(new Uri("http://blog.oppositionallydefiant.com/opml.axd"), null);
        }
Beispiel #7
0
 public void ReadSubscriptions(string opmlPath)
 {
     using (var stream = new StreamReader(opmlPath))
     {
         _opmlDocument = new OpmlDocument();
         _opmlDocument.Load(stream.BaseStream);
     }
 }
Beispiel #8
0
        private void Load(OpmlDocument opmlDocument)
        {
            rssEvents = new AutoResetEvent[opmlDocument.Body.Outlines.Count];

            LoadRssFeeds(opmlDocument);

            MergeRss(opmlDocument.Head.Title);
        }
Beispiel #9
0
        public void OpmlDocumentLoadFromXmlTest()
        {
            OpmlDocument actual = RssToolkitUnitTest.Utility.RssUtility.GetOpmlDocumentFromXml();

            Assert.IsTrue(actual.Body.Outlines.Count > 0, "RssToolkit.Opml.OpmlDocument.Load did not return the expected value.");
            Assert.AreEqual(actual.Head.Title, "mySubscriptions.opml", "RssToolkit.Opml.OpmlDocument.Load did not return the expected value.");
            Assert.AreEqual(actual.Body.Outlines[0].XmlUrl, "http://news.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss091.xml", "RssToolkit.Opml.OpmlDocument.Load did not return the expected value.");
            Assert.AreEqual(actual.Body.Outlines[1].XmlUrl, "http://news.com.com/2547-1_3-0-5.xml", "RssToolkit.Opml.OpmlDocument.Load did not return the expected value.");
        }
Beispiel #10
0
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="xml">The XML.</param>
        public void Load(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "The argument '{0}' is Null or Empty", "xml"));
            }

            OpmlDocument opmlDoc = OpmlDocument.Load(xml);

            Load(opmlDoc);
        }
Beispiel #11
0
        /// <summary>
        /// Loads from XML.
        /// </summary>
        /// <param name="xml">The XML.</param>
        public void Load(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                throw new ArgumentException(string.Format(Resources.RssToolkit.Culture, Resources.RssToolkit.ArgmentException, "xml"));
            }

            OpmlDocument opmlDoc = OpmlDocument.Load(xml);

            Load(opmlDoc);
        }
Beispiel #12
0
        /// <summary>
        /// Loads from URL.
        /// </summary>
        /// <param name="opmlUrl">The opml URL.</param>
        public void Load(System.Uri opmlUrl)
        {
            if (opmlUrl == null)
            {
                throw new ArgumentNullException("opmlUrl");
            }

            OpmlDocument opmlDoc = OpmlDocument.Load(opmlUrl);

            Load(opmlDoc);
        }
Beispiel #13
0
        public void OpmlDocumentHeadTest()
        {
            OpmlDocument target = RssToolkitUnitTest.Utility.RssUtility.GetOpmlDocumentFromXml();

            Assert.AreEqual("mySubscriptions.opml", target.Head.Title, "RssToolkit.Opml.OpmlDocument.Head was not set correctly.");
            Assert.AreEqual("Sat, 18 Jun 2005 12:11:52 GMT", target.Head.DateCreated, "RssToolkit.Opml.OpmlDocument.Head was not set correctly.");
            Assert.AreEqual("Tue, 02 Aug 2005 21:42:48 GMT", target.Head.DateModified, "RssToolkit.Opml.OpmlDocument.Head was not set correctly.");
            Assert.AreEqual("http://www.microsoft.com", target.Head.Link, "RssToolkit.Opml.OpmlDocument.Head was not set correctly.");
            Assert.AreEqual("*****@*****.**", target.Head.OwnerEmail, "RssToolkit.Opml.OpmlDocument.Head was not set correctly.");
            Assert.AreEqual("Some One", target.Head.OwnerName, "RssToolkit.Opml.OpmlDocument.Head was not set correctly.");
        }
Beispiel #14
0
        /// <summary>
        /// Provides example code for the Save(Stream) method
        /// </summary>
        public static void SaveStreamExample()
        {
            OpmlDocument document = new OpmlDocument();

            //  Modify document state using public properties and methods

            using (Stream stream = new FileStream("OpmlDocument.xml", FileMode.Create, FileAccess.Write))
            {
                document.Save(stream);
            }
        }
Beispiel #15
0
        /// <summary>
        /// Provides example code for the OpmlDocument.Create(Uri) method
        /// </summary>
        public static void CreateExample()
        {
            OpmlDocument document = OpmlDocument.Create(new Uri("http://blog.oppositionallydefiant.com/opml.axd"));

            foreach (OpmlOutline outline in document.Outlines)
            {
                if (outline.IsSubscriptionListOutline)
                {
                    //  Process outline information
                }
            }
        }
        //============================================================
        //	ASYNC METHODS
        //============================================================
        /// <summary>
        /// Provides example code for the LoadAsync(Uri, Object) method
        /// </summary>
        public static void LoadAsyncExample()
        {
            #region LoadAsync(Uri source, Object userToken)
            //------------------------------------------------------------
            //	Load resource asynchronously using event-based notification
            //------------------------------------------------------------
            OpmlDocument document = new OpmlDocument();

            document.Loaded += new EventHandler <SyndicationResourceLoadedEventArgs>(ResourceLoadedCallback);

            document.LoadAsync(new Uri("http://blog.oppositionallydefiant.com/opml.axd"), null);
            #endregion
        }
Beispiel #17
0
        public void RssAggregatorLoadTest()
        {
            RssAggregator target = new RssAggregator();

            RssToolkitUnitTest.RssToolkit_Rss_RssAggregatorAccessor accessor = new RssToolkitUnitTest.RssToolkit_Rss_RssAggregatorAccessor(target);

            OpmlDocument opmlDocument = RssToolkitUnitTest.Utility.RssUtility.GetOpmlDocumentFromXml();

            accessor.Load(opmlDocument);
            RssDocument rss = RssDocument.Load(target.RssXml);

            Assert.IsTrue(rss.Channel.Items.Count > 0);
        }
        //============================================================
        //	PUBLIC METHODS
        //============================================================
        #region Fill(OpmlDocument resource)
        /// <summary>
        /// Modifies the <see cref="OpmlDocument"/> to match the data source.
        /// </summary>
        /// <param name="resource">The <see cref="OpmlDocument"/> to be filled.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="resource"/> is a null reference (Nothing in Visual Basic).</exception>
        public void Fill(OpmlDocument resource)
        {
            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(resource, "resource");

            //------------------------------------------------------------
            //	Create namespace resolver
            //------------------------------------------------------------
            XmlNamespaceManager manager = new XmlNamespaceManager(this.Navigator.NameTable);

            //------------------------------------------------------------
            //	Attempt to fill syndication resource
            //------------------------------------------------------------
            XPathNavigator documentNavigator = this.Navigator.SelectSingleNode("opml", manager);

            if (documentNavigator != null)
            {
                XPathNavigator headNavigator = documentNavigator.SelectSingleNode("head", manager);
                if (headNavigator != null)
                {
                    resource.Head.Load(headNavigator, this.Settings);
                }

                XPathNodeIterator outlineIterator = documentNavigator.Select("body/outline", manager);
                if (outlineIterator != null && outlineIterator.Count > 0)
                {
                    int counter = 0;
                    while (outlineIterator.MoveNext())
                    {
                        OpmlOutline outline = new OpmlOutline();
                        counter++;

                        if (outline.Load(outlineIterator.Current, this.Settings))
                        {
                            if (this.Settings.RetrievalLimit != 0 && counter > this.Settings.RetrievalLimit)
                            {
                                break;
                            }

                            ((Collection <OpmlOutline>)resource.Outlines).Add(outline);
                        }
                    }
                }

                SyndicationExtensionAdapter adapter = new SyndicationExtensionAdapter(documentNavigator, this.Settings);
                adapter.Fill(resource, manager);
            }
        }
Beispiel #19
0
        /// <summary>
        /// Provides example code for the Load(Uri, ICredentials, IWebProxy) method
        /// </summary>
        public static void LoadUriExample()
        {
            OpmlDocument document = new OpmlDocument();
            Uri          source   = new Uri("http://blog.oppositionallydefiant.com/opml.axd");

            document.Load(source, CredentialCache.DefaultNetworkCredentials, null);

            foreach (OpmlOutline outline in document.Outlines)
            {
                if (outline.IsSubscriptionListOutline)
                {
                    //  Process outline information
                }
            }
        }
Beispiel #20
0
        static OpmlDocument GetRawDocument(XContainer root)
        {
            if (root == null)
            {
                return(null);
            }

            var data = new OpmlDocument
            {
                OpmlBody = GetBody(root.Descendants("body").FirstOrDefault()),
                OpmlHead = GetHead(root.Descendants("head").FirstOrDefault(), "ownerEmail", "ownerName", "title", "dateCreated", "dateModified")
            };

            return(data);
        }
Beispiel #21
0
        /// <summary>
        /// Gets the document.
        /// </summary>
        /// <param name="root">The root.</param>
        /// <param name="ns">The conventional namespace.</param>
        public static OpmlDocument GetDocument(XContainer root, XNamespace ns)
        {
            if (root == null)
            {
                return(null);
            }

            var data = new OpmlDocument
            {
                OpmlBody = GetBody(root.Element(ns.ToXName("body")), ns),
                OpmlHead = GetHead(root.Element(ns.ToXName("head")), ns)
            };

            return(data);
        }
Beispiel #22
0
        /// <summary>
        /// Provides example code for the Load(IXPathNavigable) method
        /// </summary>
        public static void LoadIXPathNavigableExample()
        {
            XPathDocument source = new XPathDocument("http://blog.oppositionallydefiant.com/opml.axd");

            OpmlDocument document = new OpmlDocument();

            document.Load(source);

            foreach (OpmlOutline outline in document.Outlines)
            {
                if (outline.IsSubscriptionListOutline)
                {
                    //  Process outline information
                }
            }
        }
Beispiel #23
0
        /// <summary>
        /// Provides example code for the Load(Stream) method
        /// </summary>
        public static void LoadStreamExample()
        {
            OpmlDocument document = new OpmlDocument();

            using (Stream stream = new FileStream("OpmlDocument.xml", FileMode.Open, FileAccess.Read))
            {
                document.Load(stream);

                foreach (OpmlOutline outline in document.Outlines)
                {
                    if (outline.IsSubscriptionListOutline)
                    {
                        //  Process outline information
                    }
                }
            }
        }
Beispiel #24
0
        /// <summary>
        /// Provides example code for the Save(XmlWriter) method
        /// </summary>
        public static void SaveXmlWriterExample()
        {
            OpmlDocument document = new OpmlDocument();

            //  Modify document state using public properties and methods

            using (Stream stream = new FileStream("OpmlDocument.xml", FileMode.Create, FileAccess.Write))
            {
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent = true;

                using (XmlWriter writer = XmlWriter.Create(stream, settings))
                {
                    document.Save(writer);
                }
            }
        }
Beispiel #25
0
        /// <summary>
        /// Provides example code for the OpmlDocument class.
        /// </summary>
        public static void ClassExample()
        {
            OpmlDocument document = new OpmlDocument();

            document.Head.Title               = "Example OPML List";
            document.Head.CreatedOn           = new DateTime(2005, 6, 18, 12, 11, 52);
            document.Head.ModifiedOn          = new DateTime(2005, 7, 2, 21, 42, 48);
            document.Head.Owner               = new OpmlOwner("John Doe", "*****@*****.**");
            document.Head.VerticalScrollState = 1;
            document.Head.Window              = new OpmlWindow(61, 304, 562, 842);

            OpmlOutline containerOutline = new OpmlOutline("Feeds");

            containerOutline.Outlines.Add(OpmlOutline.CreateSubscriptionListOutline("Argotic", "rss", new Uri("http://www.codeplex.com/Argotic/Project/ProjectRss.aspx")));
            containerOutline.Outlines.Add(OpmlOutline.CreateSubscriptionListOutline("Google News", "feed", new Uri("http://news.google.com/?output=atom")));
            document.AddOutline(containerOutline);
        }
        /// <summary>
        /// Modifies the <see cref="ISyndicationResource"/> to match the data source.
        /// </summary>
        /// <param name="resource">The Outline Processor Markup Language (OPML) <see cref="ISyndicationResource"/> to be filled.</param>
        /// <param name="resourceMetadata">A <see cref="SyndicationResourceMetadata"/> object that represents the meta-data describing the <paramref name="resource"/>.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="resource"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="resourceMetadata"/> is a null reference (Nothing in Visual Basic).</exception>
        private void FillOpmlResource(ISyndicationResource resource, SyndicationResourceMetadata resourceMetadata)
        {
            Guard.ArgumentNotNull(resource, "resource");
            Guard.ArgumentNotNull(resourceMetadata, "resourceMetadata");

            OpmlDocument opmlDocument = resource as OpmlDocument;
            Opml20SyndicationResourceAdapter opml20Adapter = new Opml20SyndicationResourceAdapter(this.Navigator, this.Settings);

            if (resourceMetadata.Version == new Version("2.0"))
            {
                opml20Adapter.Fill(opmlDocument);
            }

            if (resourceMetadata.Version == new Version("1.1"))
            {
                opml20Adapter.Fill(opmlDocument);
            }

            if (resourceMetadata.Version == new Version("1.0"))
            {
                opml20Adapter.Fill(opmlDocument);
            }
        }
Beispiel #27
0
        /// <summary>
        /// Instantiates a <see cref="ISyndicationResource"/> that conforms to the specified <see cref="SyndicationContentFormat"/> using the supplied <see cref="Stream"/>.
        /// </summary>
        /// <param name="stream">The <see cref="Stream"/> used to load the syndication resource.</param>
        /// <param name="format">A <see cref="SyndicationContentFormat"/> enumeration value that indicates the type syndication resource the <paramref name="stream"/> represents.</param>
        /// <returns>
        ///     An <see cref="ISyndicationResource"/> object that conforms to the specified <paramref name="format"/>, initialized using the supplied <paramref name="stream"/>.
        ///     If the <paramref name="format"/> is not supported by the provider, returns a <b>null</b> reference.
        /// </returns>
        /// <exception cref="ArgumentNullException">The <paramref name="stream"/> is a null reference (Nothing in Visual Basic).</exception>
        private static ISyndicationResource BuildResource(SyndicationContentFormat format, Stream stream)
        {
            Guard.ArgumentNotNull(stream, "stream");

            if (format == SyndicationContentFormat.Apml)
            {
                ApmlDocument document = new ApmlDocument();
                document.Load(stream);
                return(document);
            }
            else if (format == SyndicationContentFormat.Atom)
            {
                XPathDocument  document  = new XPathDocument(stream);
                XPathNavigator navigator = document.CreateNavigator();
                navigator.MoveToRoot();
                navigator.MoveToChild(XPathNodeType.Element);

                if (String.Compare(navigator.LocalName, "entry", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    AtomEntry entry = new AtomEntry();
                    entry.Load(navigator);
                    return(entry);
                }
                else if (String.Compare(navigator.LocalName, "feed", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    AtomFeed feed = new AtomFeed();
                    feed.Load(navigator);
                    return(feed);
                }
                else
                {
                    return(null);
                }
            }
            else if (format == SyndicationContentFormat.BlogML)
            {
                BlogMLDocument document = new BlogMLDocument();
                document.Load(stream);
                return(document);
            }
            else if (format == SyndicationContentFormat.Opml)
            {
                OpmlDocument document = new OpmlDocument();
                document.Load(stream);
                return(document);
            }
            else if (format == SyndicationContentFormat.Rsd)
            {
                RsdDocument document = new RsdDocument();
                document.Load(stream);
                return(document);
            }
            else if (format == SyndicationContentFormat.Rss)
            {
                RssFeed feed = new RssFeed();
                feed.Load(stream);
                return(feed);
            }
            else
            {
                return(null);
            }
        }
Beispiel #28
0
 /// <summary>
 /// Generates an index from <see cref="IEnumerable{BlogEntry}"/>.
 /// </summary>
 /// <param name="entries">The entries.</param>
 /// <param name="topics">The topics.</param>
 /// <returns></returns>
 /// <exception cref="System.NullReferenceException">
 /// The expected Blog entries are not here.
 /// or
 /// The expected Blog entries are not here.
 /// or
 /// The expected Blog topics are not here.
 /// </exception>
 public static string GenerateIndex(this IEnumerable <BlogEntry> entries, OpmlDocument topics)
 {
     return(entries.GenerateIndex(topics, useJavaScriptCase: false));
 }
Beispiel #29
0
 public static void MyClassInitialize(TestContext testContext)
 {
     target = RssToolkitUnitTest.Utility.RssUtility.GetOpmlDocumentFromXml();
 }
        /// <summary>
        /// Returns a date-time indicating the most recent instant in time when the resource was last modified.
        /// </summary>
        /// <param name="resource">The <see cref="ISyndicationResource"/> to determine the modification date for.</param>
        /// <returns>
        ///     A <see cref="DateTime"/> indicating the most recent instant in time when the <see cref="ISyndicationResource"/> was last modified.
        ///     If the <see cref="ISyndicationResource"/> conforms to a format that does not support modification tracking, or if otherwise unable
        ///     to determine the modification date, returns <see cref="DateTime.MinValue"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">The <paramref name="resource"/> is a null reference (Nothing in Visual Basic).</exception>
        private static DateTime GetLastModificationDate(ISyndicationResource resource)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            DateTime lastModifiedOn = DateTime.MinValue;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(resource, "resource");

            //------------------------------------------------------------
            //	Determine modification date based on format specific details
            //------------------------------------------------------------
            switch (resource.Format)
            {
            case SyndicationContentFormat.Apml:
                ApmlDocument apmlDocument = resource as ApmlDocument;
                if (apmlDocument != null && apmlDocument.Head != null)
                {
                    lastModifiedOn = apmlDocument.Head.CreatedOn;
                }
                break;

            case SyndicationContentFormat.Atom:
                XPathNavigator rootNavigator = resource.CreateNavigator();
                if (String.Compare(rootNavigator.LocalName, "entry", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    AtomEntry entry = resource as AtomEntry;
                    if (entry != null)
                    {
                        lastModifiedOn = entry.UpdatedOn;
                    }
                }
                else if (String.Compare(rootNavigator.LocalName, "feed", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    AtomFeed atomFeed = resource as AtomFeed;
                    if (atomFeed != null)
                    {
                        lastModifiedOn = atomFeed.UpdatedOn;
                    }
                }
                break;

            case SyndicationContentFormat.BlogML:
                BlogMLDocument blogDocument = resource as BlogMLDocument;
                if (blogDocument != null)
                {
                    lastModifiedOn = blogDocument.GeneratedOn;
                }
                break;

            case SyndicationContentFormat.Opml:
                OpmlDocument opmlDocument = resource as OpmlDocument;
                if (opmlDocument != null && opmlDocument.Head != null)
                {
                    lastModifiedOn = opmlDocument.Head.ModifiedOn;
                }
                break;

            case SyndicationContentFormat.Rsd:
                //  RSD 1.0 does not provide last modified information
                lastModifiedOn = DateTime.MinValue;
                break;

            case SyndicationContentFormat.Rss:
                RssFeed rssFeed = resource as RssFeed;
                if (rssFeed != null && rssFeed.Channel != null)
                {
                    lastModifiedOn = rssFeed.Channel.LastBuildDate;
                }
                break;

            default:
                lastModifiedOn = DateTime.MinValue;
                break;
            }

            return(lastModifiedOn);
        }