コード例 #1
0
        List <VideoInfo> GetVideoForCurrentCategory()
        {
            string      finalUrl = string.Format("{0}&max-results={1}&start-index={2}", currentCategory.Url, pageSize, currentStart);
            RssDocument rss      = GetWebData <RssDocument>(finalUrl);

            currentCategory.EstimatedVideoCount = (uint)rss.Channel.TotalResults;
            List <VideoInfo> videoList = new List <VideoInfo>();

            foreach (RssItem rssItem in rss.Channel.Items)
            {
                VideoInfo video = new VideoInfo();
                video.Title = rssItem.Description.Substring(0, rssItem.Description.LastIndexOf('|') - 1).Replace('|', '-');
                if (rssItem.MediaThumbnails.Count > 0)
                {
                    video.Thumb = rssItem.MediaThumbnails[Math.Min(rssItem.MediaThumbnails.Count, rssItem.MediaThumbnails.Count / 2)].Url;
                }
                if (rssItem.MediaContents.Count > 0)
                {
                    video.Length   = ((int)float.Parse(rssItem.MediaContents[0].Duration, new System.Globalization.CultureInfo("en-us"))).ToString();
                    video.VideoUrl = rssItem.MediaContents[0].Url;
                    videoList.Add(video);
                }
            }
            return(videoList);
        }
コード例 #2
0
        public void RssXmlHelperDeserializeFromXmlUsingStringReaderTest()
        {
            RssDocument rss = RssXmlHelper.DeserializeFromXmlUsingStringReader <RssDocument>(rssXml);

            Assert.IsTrue(rss.Channel.Items.Count == 1, "RssToolkit.RssRssXmlHelper.DeserializeFromXmlUsingStringReader did not return the expected value.");
            Assert.IsTrue(rss.Channel.Title == "Yahoo! News: Top Stories", "RssToolkit.Rss.RssXmlHelper.DeserializeFromXmlUsingStringReader did not return the expected value.");
        }
コード例 #3
0
        public void RssCodeGeneratorGenerateCodeDomTreeTest()
        {
            RssDocument  rssDefinition   = RssUtility.GetRssDocumentFromUrl();
            string       namespaceName   = "test";
            string       outputLanguage  = "cs";
            string       classNamePrefix = "Test";
            StringWriter outputCode      = new StringWriter();
            bool         useBaseClass    = true;
            // generate the CodeDom tree
            // get the CodeDom provider for the language
            CodeDomProvider provider = CodeDomProvider.CreateProvider(outputLanguage);
            CodeCompileUnit unit     = new CodeCompileUnit();

            RssToolkit.Rss.CodeGeneration.RssCodeGenerator.GenerateCodeDomTree(rssDefinition, namespaceName, classNamePrefix, unit, useBaseClass);

            // generate source
            CodeGeneratorOptions options = new CodeGeneratorOptions();

            options.BlankLinesBetweenMembers = true;
            options.BracingStyle             = "Block";
            options.ElseOnClosing            = false;
            options.IndentString             = "    ";

            provider.GenerateCodeFromCompileUnit(unit, outputCode, options);

            TestConditions(outputCode.ToString());
        }
コード例 #4
0
ファイル: RssHelper.cs プロジェクト: cdc1979/Writa
        public string GenerateRss(string baseurl)
        {
            RssDocument r = new RssDocument();
            RssChannel  c = new RssChannel();

            c.Items = new List <RssItem>();

            foreach (WritaPost p in _dbhelper.GetPosts())
            {
                c.Items.Add(new RssItem()
                {
                    Link = baseurl + "/" + p.PostSlug, Title = p.PostTitle, Description = p.PostSummary
                });
            }

            r.Channel = c;
            r.Version = "2.0";

            string      doc      = r.ToXml(DocumentType.Atom);
            XmlDocument document = new XmlDocument();

            document.LoadXml(doc);
            //context.Response.ContentType = "text/xml";
            document.Save(HttpContext.Current.Server.MapPath("~/atom.rss"));
            return(doc);
        }
コード例 #5
0
        public void RssDocumentToDataSetTest()
        {
            RssDocument rss     = RssUtility.GetRssDocumentFromUrl();
            DataSet     dataSet = rss.ToDataSet();

            Assert.IsTrue(dataSet.Tables["item"].Rows.Count > 0, "RssToolkit.Rss.RssDocument.ToDataSet did not return the expected value.");
        }
コード例 #6
0
        public void RssDocumentUrlTest()
        {
            RssDocument target = RssUtility.GetRssDocumentFromUrl();
            string      val    = RssUtility.RssUrl;

            RssToolkitUnitTest.RssToolkit_Rss_RssDocumentAccessor accessor = new RssToolkitUnitTest.RssToolkit_Rss_RssDocumentAccessor(target);
            Assert.AreEqual(val, accessor.Url, "RssToolkit.Rss.RssDocument.Url was not set correctly.");
        }
コード例 #7
0
 public void RssDocumentMultipleUrlTest()
 {
     foreach (string url in RssUtility.RssUrls)
     {
         rss = RssDocument.Load(new System.Uri(url));
         Assert.IsTrue(rss.Channel.Items.Count > 0);
     }
 }
コード例 #8
0
        public void RssXmlHelperConvertToRssTest()
        {
            RssDocument rss = RssDocument.Load(RssXmlHelper.ConvertToRssXml(RssUtility.AtomXml));

            Assert.IsTrue(rss.Channel.Items.Count > 0);

            rss = RssDocument.Load(RssXmlHelper.ConvertToRssXml(RssUtility.RdfXml));
            Assert.IsTrue(rss.Channel.Items.Count > 0);
        }
コード例 #9
0
        public async Task <IActionResult> GetRssFeed()
        {
            var key = "rss";
            var xml = _cache.Get(key)?.ToString();

            if (string.IsNullOrEmpty(xml))
            {
                int?categoryId  = null;
                var pagedResult = await _publicationManager.GetPublications(categoryId, 1, 50);

                var lastUpdateDate = pagedResult.Select(o => o.DateTime).DefaultIfEmpty().Max();

                var rss = new RssDocument
                {
                    Channel =
                        new RssChannel
                    {
                        Copyright   = _settings.WebSiteTitle,
                        Description = _settings.DefaultDescription,
                        SkipDays    = new List <Day>(),
                        SkipHours   = new List <Hour>(),
                        AtomLink    = new RssLink(_settings.RssFeedUrl),
                        Image       = new RssImage
                        {
                            Description = _settings.WebSiteTitle,
                            Height      = 100,
                            Width       = 100,
                            Link        = new RssUrl(_settings.FacebookImage),
                            Title       = _settings.WebSiteTitle,
                            Url         = new RssUrl(_settings.FacebookImage)
                        },
                        Language       = new CultureInfo("ru"),
                        LastBuildDate  = lastUpdateDate,
                        Link           = new RssUrl(_settings.RssFeedUrl),
                        ManagingEditor = new RssPerson("Andrew G.", _settings.SupportEmail),
                        PubDate        = lastUpdateDate,
                        Title          = _settings.WebSiteTitle,
                        TTL            = 10,
                        WebMaster      = new RssPerson("Andrew G.", _settings.SupportEmail),
                        Items          = new List <RssItem> {
                        }
                    }
                };

                foreach (var p in pagedResult)
                {
                    rss.Channel.Items.Add(CreateRssItem(p));
                }

                xml = rss.ToXml();

                _cache.Set(key, xml, TimeSpan.FromMinutes(10));
            }

            return(Content(xml, RssDocument.MimeType));
        }
コード例 #10
0
        public void RssDocumentChannelTest()
        {
            rss = RssToolkitUnitTest.Utility.RssUtility.GetRssDocumentFromXml();

            Assert.AreEqual(rss.Channel.Categories[0].Domain, "http://www.microsoft.com");
            Assert.AreEqual(rss.Channel.Categories[1].Domain, "http://www.yahoo.com");
            Assert.AreEqual(rss.Channel.Categories[0].Text, "MSFT");
            Assert.AreEqual(rss.Channel.Categories[1].Text, "YHOO");
            Assert.AreEqual(rss.Channel.Cloud.Domain, "rpc.sys.com");
            Assert.AreEqual(rss.Channel.Cloud.Path, "/RPC2");
            Assert.AreEqual(rss.Channel.Cloud.Port, "80");
            Assert.AreEqual(rss.Channel.Cloud.Protocol, "soap");
            Assert.AreEqual(rss.Channel.Cloud.RegisterProcedure, "pingMe");
            Assert.AreEqual("Copyright (c) 2007 Yahoo! Inc. All rights reserved.", rss.Channel.Copyright);
            Assert.AreEqual("Top Stories", rss.Channel.Description);
            Assert.AreEqual("http://blogs.law.harvard.edu/tech/rss", rss.Channel.Docs);
            Assert.AreEqual("MightyInHouse Content System v2.3", rss.Channel.Generator);
            Assert.AreEqual("Yahoo News on the hour.", rss.Channel.Image.Description, "RssToolkit.Rss.RssImage.Description was not set correctly.");
            Assert.AreEqual("18", rss.Channel.Image.Height, "RssToolkit.Rss.RssImage.Height was not set correctly.");
            Assert.AreEqual("http://news.yahoo.com/i/716", rss.Channel.Image.Link, "RssToolkit.Rss.RssImage.Link was not set correctly.");
            Assert.AreEqual("Yahoo! News", rss.Channel.Image.Title, "RssToolkit.Rss.RssImage.Title was not set correctly.");
            Assert.AreEqual("http://us.i1.yimg.com/us.yimg.com/i/us/nws/th/main_142b.gif", rss.Channel.Image.Url, "RssToolkit.Rss.RssImage.Url was not set correctly.");
            Assert.AreEqual("142", rss.Channel.Image.Width, "RssToolkit.Rss.RssImage.Width was not set correctly.");
            Assert.AreEqual("*****@*****.**", rss.Channel.Items[0].Author, "RssToolkit.Rss.RssItem.Author was not set correctly.");
            Assert.AreEqual(rss.Channel.Items[0].Categories[0].Domain, "http://www.google.com");
            Assert.AreEqual(rss.Channel.Items[0].Categories[1].Domain, "http://www.sun.com");
            Assert.AreEqual(rss.Channel.Items[0].Categories[0].Text, "GOOG");
            Assert.AreEqual(rss.Channel.Items[0].Categories[1].Text, "SUNW");
            Assert.AreEqual("This feed is from Yahoo News", rss.Channel.Items[0].Comments, "RssToolkit.Rss.RssItem.Comments was not set correctly.");
            Assert.AreEqual("This is a feed description", rss.Channel.Items[0].Description, "RssToolkit.Rss.RssItem.Description was not set correctly.");
            Assert.AreEqual("12216320", rss.Channel.Items[0].Enclosure.Length, "RssToolkit.Rss.RssEnclosure.Length was not set correctly.");
            Assert.AreEqual("audio/mpeg", rss.Channel.Items[0].Enclosure.Type, "RssToolkit.Rss.RssEnclosure.Type was not set correctly.");
            Assert.AreEqual("http://www.scripting.com/mp3s/weatherReportSuite.mp3", rss.Channel.Items[0].Enclosure.Url, "RssToolkit.Rss.RssEnclosure.Url was not set correctly.");
            Assert.AreEqual("false", rss.Channel.Items[0].Guid.IsPermaLink, "RssToolkit.Rss.RssGuid.IsPermaLink was not set correctly.");
            Assert.AreEqual("ap/20070214/bush", rss.Channel.Items[0].Guid.Text, "RssToolkit.Rss.RssGuid.Text was not set correctly.");
            Assert.AreEqual("http://us.rd.yahoo.com/dailynews/rss/topstories/*http://news.yahoo.com/s/ap/20070214/ap_on_go_pr_wh/bush", rss.Channel.Items[0].Link, "RssToolkit.Rss.RssItem.Link was not set correctly.");
            Assert.AreEqual("Wed, 14 Feb 2007 23:05:49 GMT", rss.Channel.Items[0].PubDate, "RssToolkit.Rss.RssItem.PubDate was not set correctly.");
            Assert.AreEqual("Bush: Iran is source of deadly weapons", rss.Channel.Items[0].Title, "RssToolkit.Rss.RssItem.Title was not set correctly.");
            Assert.AreEqual("Wed, 14 Feb 2007 23:10:27 GMT", rss.Channel.LastBuildDate);
            Assert.AreEqual("http://news.yahoo.com/i/716", rss.Channel.Link);
            Assert.AreEqual("*****@*****.**", rss.Channel.ManagingEditor);
            Assert.AreEqual("Wed, 14 Feb 2007 23:05:49 GMT", rss.Channel.PubDate);
            Assert.AreEqual("10", rss.Channel.Rating);
            Assert.AreEqual("Tuesday", rss.Channel.SkipDays.Days[0], "RssToolkit.Rss.RssSkipHours.Hours was not set correctly.");
            Assert.AreEqual("Friday", rss.Channel.SkipDays.Days[1], "RssToolkit.Rss.RssSkipHours.Hours was not set correctly.");
            Assert.AreEqual("0", rss.Channel.SkipHours.Hours[0], "RssToolkit.Rss.RssSkipHours.Hours was not set correctly.");
            Assert.AreEqual("1", rss.Channel.SkipHours.Hours[1], "RssToolkit.Rss.RssSkipHours.Hours was not set correctly.");
            Assert.AreEqual("5", rss.Channel.TimeToLive);
            Assert.AreEqual("Yahoo! News: Top Stories", rss.Channel.Title);
            Assert.AreEqual("*****@*****.**", rss.Channel.WebMaster);
            Assert.AreEqual("en-us", rss.Channel.Language);
            Assert.AreEqual("Explains the text input area.", rss.Channel.TextInput.Description, "RssToolkit.Rss.RssTextInput.Description was not set correctly.");
            Assert.AreEqual("The URL of the CGI script that processes text input requests.", rss.Channel.TextInput.Link, "RssToolkit.Rss.RssTextInput.Description was not set correctly.");
            Assert.AreEqual("The name of the text object in the text input area.", rss.Channel.TextInput.Name, "RssToolkit.Rss.RssTextInput.Description was not set correctly.");
            Assert.AreEqual("The label of the Submit button in the text input area.", rss.Channel.TextInput.Title, "RssToolkit.Rss.RssTextInput.Description was not set correctly.");
        }
コード例 #11
0
        public void RssDocumentSelectItemsTest()
        {
            RssDocument target = RssUtility.GetRssDocumentFromUrl();
            IEnumerable actual;

            actual = target.SelectItems();
            System.Data.DataView view = (System.Data.DataView)target.SelectItems();
            Assert.IsTrue(actual.GetEnumerator().MoveNext(), "RssToolkit.Rss.RssDocument.SelectItems did not return the expected value.");
            Assert.IsTrue(view.Table.Rows.Count > 0, "RssToolkit.Rss.RssDocument.SelectItems did not return the expected value.");
        }
コード例 #12
0
        public void RssAggregatorLoadFromUrlTest()
        {
            RssAggregator target  = new RssAggregator();
            string        opmlUrl = RssToolkitUnitTest.Utility.RssUtility.OpmlUrl;

            target.Load(new System.Uri(opmlUrl));
            RssDocument rss = RssDocument.Load(target.RssXml);

            Assert.IsTrue(rss.Channel.Items.Count > 0);
        }
コード例 #13
0
        public void RssDocumentVersionTest()
        {
            RssDocument target = RssUtility.GetRssDocumentFromUrl();

            Assert.AreEqual("2.0", target.Version, "RssToolkit.Rss.RssDocument.Version was not set correctly.");
            string val = "1.0";

            target.Version = val;
            Assert.AreEqual(val, target.Version, "RssToolkit.Rss.RssDocument.Version was not set correctly.");
        }
コード例 #14
0
        public void WriteRead_LargeObject_Ok()
        {
            var ms  = new MemoryStream();
            var rss = GetFullRss();

            RssDocument.WriteRSS(rss, ms);
            ms.Position = 0;
            var newRss = RssDocument.Load(ms);

            Assert.AreEqual(rss.Channel.Description, newRss.Channel.Description);
        }
コード例 #15
0
        public void Test()
        {
            var request  = WebRequest.Create("http://bash.im/rss/");
            var response = request.GetResponse();
            var stream   = response.GetResponseStream();

            var rss = RssDocument.Load(stream);

            Assert.AreEqual("Bash.im", rss.Channel.Title);
            Assert.AreEqual("Цитатник Рунета", rss.Channel.Description);
        }
コード例 #16
0
        public void Test()
        {
            var request  = WebRequest.Create("https://news.microsoft.com/feed/");
            var response = request.GetResponse();
            var stream   = response.GetResponseStream();

            var rss = RssDocument.Load(stream);

            Assert.Equal("Stories", rss.Channel.Title);
            Assert.Equal("Microsoft news, features, events, and press materials", rss.Channel.Description);
        }
コード例 #17
0
        public void RssDocumentSelectItemsTest2()
        {
            RssDocument target       = RssUtility.GetRssDocumentFromUrl();
            int         maxItems     = 10;
            bool        reverseOrder = true;
            IEnumerable actual       = target.SelectItems(maxItems, reverseOrder);

            System.Data.DataView view = (System.Data.DataView)target.SelectItems(maxItems, reverseOrder);
            Assert.IsTrue(actual.GetEnumerator().MoveNext(), "RssToolkit.Rss.RssDocument.SelectItems did not return the expected value.");
            Assert.IsTrue(view.Table.Rows.Count == 10, "RssToolkit.Rss.RssDocument.SelectItems did not return the expected value.");
        }
コード例 #18
0
        public void RssXmlHelperToRssXmlTest()
        {
            string      rssUrl = "http://rss.msnbc.msn.com/id/3032091/device/rss/rss.xml";
            RssDocument rss    = RssDocument.Load(new System.Uri(rssUrl));
            string      xml    = RssXmlHelper.ToRssXml <RssDocument>(rss);

            Assert.IsFalse(string.IsNullOrEmpty(xml), "RssToolkit.Rss.RssXmlHelper.ToRssXml did not return the expected value.");
            System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
            xmlDocument.LoadXml(xml);
            Assert.IsTrue(xmlDocument.DocumentElement.LocalName.Equals("rss", StringComparison.OrdinalIgnoreCase), "RssToolkit.Rss.RssXmlHelper.ToRssXml did not return the expected value.");
            Assert.IsTrue(xmlDocument.SelectNodes("/rss/channel/item").Count > 0, "RssToolkit.Rss.RssXmlHelper.ToRssXml did not return the expected value.");
        }
コード例 #19
0
        public void RssCodeGeneratorGenerateCodeTest()
        {
            RssDocument  rssDefinition   = RssUtility.GetRssDocumentFromUrl();
            string       outputLanguage  = "cs";
            string       namespaceName   = "test";
            string       classNamePrefix = "Test";
            StringWriter outputCode      = new StringWriter();
            bool         useBaseClass    = true;

            RssToolkit.Rss.CodeGeneration.RssCodeGenerator.GenerateCode(rssDefinition, outputLanguage, namespaceName, classNamePrefix, outputCode, useBaseClass);
            TestConditions(outputCode.ToString());
        }
コード例 #20
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);
        }
コード例 #21
0
        public void Read_External_Ok()
        {
            var ms    = new MemoryStream();
            var array = Encoding.UTF8.GetBytes(GetPartRssText());

            ms.Write(array, 0, array.Length);
            ms.Position = 0;

            var rss = RssDocument.Load(ms);

            Assert.AreEqual("channel title", rss.Channel.Title);
            Assert.AreEqual("long description", rss.Channel.Description);
        }
コード例 #22
0
        /// <summary>
        /// Binds the RSS news.
        /// </summary>
        private void BindRssNews()
        {
            string ss = "";

            if (!String.IsNullOrEmpty(RssPath))
            {
                RssDocument rssDocument = null;

                try
                {
                    rssDocument = RssDocument.Load(new Uri(RssPath));
                }
                catch
                {
                    Response.ContentType = "text/xml";
                    Response.Write("<div style='text-align:center;padding:10px;color:red;' class='text'>" + RM.GetString("RSS_ERROR") + "</div>");
                    return;
                }

                // Create root element
                XmlDocument doc  = new XmlDocument();
                XmlNode     root = doc.AppendChild(doc.CreateElement("rssData"));
                XmlNode     node = doc.CreateElement("htmlData");

                RssChannel channel = rssDocument.Channel;

                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("<div>");
                sb.AppendFormat("<div style='padding-top: 3px;padding-bottom:3px;color: #444;font-size: 10pt;'><b>{0}</b></div>", channel.Title);
                for (int i = 0; i < channel.Items.Count && i < RssCount; i++)
                {
                    sb.AppendFormat("<div style='padding-top: 3px;' class='text'><a href='{1}' target='_blank'>{0}</a></div>", channel.Items[i].Title, channel.Items[i].Link);
                    sb.AppendFormat("<div style='color: gray;' class='text'>{0}</div>", channel.Items[i].PubDate);
                    //sb.AppendFormat("<div style='color: black; font-family: tahoma; font-size: 12px;'>{0}</div>", channel.Items[i].Attributes["description"]);
                }
                sb.Append("</div>");
                XmlNode cdata = doc.CreateCDataSection(sb.ToString());
                //node.Name = "htmlData";
                node.AppendChild(cdata);
                root.AppendChild(node);
                //doc.DocumentElement.AppendChild(doc.CreateCDataSection(sb.ToString()));
                ss += doc.InnerText;
            }
            Response.ContentType = "text/xml";
            Response.Write(ss);
        }
コード例 #23
0
        public void DownloadManagerGetFeedTest()
        {
            string url = RssToolkitUnitTest.Utility.RssUtility.RssUrl;

            using (Stream actual = RssToolkit.Rss.DownloadManager.GetFeed(url))
            {
                using (XmlTextReader reader = new XmlTextReader(actual))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            break;
                        }
                    }

                    string      outerXml = reader.ReadOuterXml();
                    RssDocument rss      = RssDocument.Load(outerXml);
                    Assert.IsTrue(outerXml.Length > 0, "RssToolkit.Rss.DownloadManager.GetFeed did not return the expected value.");
                    Assert.IsTrue(rss.Channel.Items.Count > 0, "RssToolkit.Rss.DownloadManager.GetFeed did not return the expected value.");
                }
            }

            url = RssToolkitUnitTest.Utility.RssUtility.OpmlUrl;
            using (Stream actual = RssToolkit.Rss.DownloadManager.GetFeed(url))
            {
                using (XmlTextReader reader = new XmlTextReader(actual))
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            break;
                        }
                    }

                    string      outerXml = reader.ReadOuterXml();
                    RssDocument rss      = RssDocument.Load(outerXml);
                    Assert.IsTrue(actual.Length > 0, "RssToolkit.Rss.DownloadManager.GetFeed did not return the expected value.");
                    Assert.IsTrue(rss.Channel.Items.Count > 0, "RssToolkit.Rss.DownloadManager.GetFeed did not return the expected value.");
                }
            }
        }
コード例 #24
0
ファイル: Feed.cs プロジェクト: harder/GraffitiCMS
        internal void ReLoad(bool throwExceptionOnError)
        {
            try
            {
                LastRequested = DateTime.Now;
                RssDocument doc = RssDocument.Load(new Uri(Url));
                Document = doc;
                LastSuccessfulRequest = DateTime.Now;
                Log.Info("Feed", "The feed {0} was successfully updated", Url);
            }
            catch (Exception ex)
            {
                Log.Error("Feed", "The feed {0} (Name:{2} Id:{3} was not successfully updated. Reason: {1}", Url, ex.Message, Name, Id);

                if (throwExceptionOnError)
                {
                    throw;
                }
            }
        }
コード例 #25
0
ファイル: RssGenerator.cs プロジェクト: alex765022/IBN
        /// <summary>
        /// Generates the specified param.
        /// </summary>
        /// <returns></returns>
        public string Generate()
        {
            ResolveListViewProfile();

            RssDocument rssDocument = new RssDocument();

            rssDocument.Version = "2.0";

            rssDocument.Channel       = new RssChannel();
            rssDocument.Channel.Image = new RssImage();

            GenerateChannelInformation(rssDocument.Channel);

            rssDocument.Channel.Copyright = IbnConst.AssemblyCopyright;
            rssDocument.Channel.Generator = IbnConst.AssemblyCompany + "RSS Generator";
            rssDocument.Channel.WebMaster = "";

            rssDocument.Channel.Image.Link  = MakeFullLink(this.Page.ResolveUrl("~/"));
            rssDocument.Channel.Image.Title = IbnConst.ProductName;
            rssDocument.Channel.TimeToLive  = "30";

            rssDocument.Channel.Items         = new List <RssItem>();
            rssDocument.Channel.LastBuildDate = GenerateChannelItems(rssDocument.Channel);

            //dvs[2009-05-28]: fix bug with ie (set encoding to utf-8)
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(rssDocument.ToXml(DocumentType.Rss));
            if (xmlDoc.FirstChild.NodeType == XmlNodeType.XmlDeclaration)
            {
                XmlDeclaration xmlDeclaration = (XmlDeclaration)xmlDoc.FirstChild;
                xmlDeclaration.Encoding = "utf-8";
            }

            StringWriter  sw = new StringWriter();
            XmlTextWriter xw = new XmlTextWriter(sw);

            xmlDoc.WriteTo(xw);
            return(sw.ToString());
        }
コード例 #26
0
        public void RssDocumentToXmlTest()
        {
            RssDocument rss = RssUtility.GetRssDocumentFromUrl();
            string      xml = rss.ToXml(DocumentType.Rss);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            Assert.IsTrue(doc.SelectNodes("/rss/channel/item").Count > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
            Assert.IsTrue(doc.SelectSingleNode("/rss/channel/title").InnerText.Length > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
            Assert.IsTrue(doc.SelectSingleNode("/rss/channel/item/title").InnerText.Length > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");

            xml = rss.ToXml(DocumentType.Atom);
            doc.LoadXml(xml);
            Assert.IsTrue(doc.SelectNodes("/feed/entry").Count > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
            Assert.IsTrue(doc.SelectSingleNode("/feed/title").InnerText.Length > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
            Assert.IsTrue(doc.SelectSingleNode("/feed/entry/summary").InnerText.Length > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");

            xml = rss.ToXml(DocumentType.Rdf);
            doc.LoadXml(xml);
            Assert.IsTrue(doc.SelectNodes("/rdf/item").Count > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
            Assert.IsTrue(doc.SelectSingleNode("/rdf/channel/title").InnerText.Length > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
            Assert.IsTrue(doc.SelectSingleNode("/rdf/item/title").InnerText.Length > 0, "RssToolkit.Rss.RssDocument.ToXml did not return the expected value.");
        }
コード例 #27
0
        private void button1_Click(object sender, EventArgs e)
        {
            string url = urlComboBox.Text;

            if (url != _dataSource.Url)
            {
                try
                {
                    RssDocument rss = RssDocument.Load(new System.Uri(url));
                    lock (_history)
                    {
                        AddToHistory(url);
                    }
                }
                catch
                {
                    MessageBox.Show(this, "Failed to load RSS feed for the specified URL", "RssDataSource Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            _dataSource.Url = url;
            DialogResult    = DialogResult.OK;
        }
コード例 #28
0
 public static void MyClassInitialize(TestContext testContext)
 {
     rss = RssToolkitUnitTest.Utility.RssUtility.GetRssDocumentFromXml();
 }
コード例 #29
0
        public static RssDocument GetRssDocumentFromOpmlXml()
        {
            RssDocument rss = RssDocument.Load(OpmlXml);

            return(rss);
        }
コード例 #30
0
        public void RssDocumentLoadRssFromXmlTest()
        {
            RssDocument actual = RssUtility.GetRssDocumentFromXml();

            Assert.IsTrue(actual.Channel.Items.Count > 0, "RssToolkit.Rss.RssDocument.Load did not return the expected value.");
        }