当前位置: 首页>>代码示例>>C#>>正文


C# Syndication.Rss20FeedFormatter类代码示例

本文整理汇总了C#中System.ServiceModel.Syndication.Rss20FeedFormatter的典型用法代码示例。如果您正苦于以下问题:C# Rss20FeedFormatter类的具体用法?C# Rss20FeedFormatter怎么用?C# Rss20FeedFormatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Rss20FeedFormatter类属于System.ServiceModel.Syndication命名空间,在下文中一共展示了Rss20FeedFormatter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetFeeds

        public static IList<Feed> GetFeeds()
        {
            var urls = new[]
                {
                    "http://www.simplyvinay.com/GetBlogRss.aspx", "http://www.bbc.co.uk/blogs/formula1/rss.xml",
                    "http://feeds.feedburner.com/AyendeRahien"
                };
            var list = new List<Feed>();

            foreach (var url in urls)
            {
                using (var reader = new CustomXmlReader(url))
                {
                    if (reader.ReadState == ReadState.Initial)
                        reader.MoveToContent();

                    var atom = new Atom10FeedFormatter();
                    if (atom.CanRead(reader))
                    {
                        atom.ReadFrom(reader);
                        list.AddRange(GenerateFeed(atom.Feed, true));
                    }

                    var rss = new Rss20FeedFormatter();
                    if (rss.CanRead(reader))
                    {
                        rss.ReadFrom(reader);
                        list.AddRange(GenerateFeed(rss.Feed, false));
                    }
                }
            }
            return list;
        }
开发者ID:simplyvinay,项目名称:feedreader,代码行数:33,代码来源:Program.cs

示例2: WriteFile

        protected override void WriteFile(System.Web.HttpResponseBase response)
        {
            var items = new List<SyndicationItem>();

            foreach (Dinner d in this.Dinners)
            {
                string contentString = String.Format("{0} with {1} on {2:MMM dd, yyyy} at {3}. Where: {4}, {5}",
                            d.Description, d.HostedBy, d.EventDate, d.EventDate.ToShortTimeString(), d.Address, d.Country);

                var item = new SyndicationItem(
                    title: d.Title,
                    content: contentString,
                    itemAlternateLink: new Uri("http://nrddnr.com/" + d.DinnerID),
                    id: "http://nrddnr.com/" + d.DinnerID,
                    lastUpdatedTime: d.EventDate.ToUniversalTime()
                    );
                item.PublishDate = d.EventDate.ToUniversalTime();
                item.Summary = new TextSyndicationContent(contentString, TextSyndicationContentKind.Plaintext);
                items.Add(item);
            }

            SyndicationFeed feed = new SyndicationFeed(
                this.Title,
                this.Title, /* Using Title also as Description */
                currentUrl,
                items);

            Rss20FeedFormatter formatter = new Rss20FeedFormatter(feed);

            using (XmlWriter writer = XmlWriter.Create(response.Output))
            {
                formatter.WriteTo(writer);
            }
        }
开发者ID:ruisebastiao,项目名称:nerddinner,代码行数:34,代码来源:RSSResult.cs

示例3: CreateFeed

        public SyndicationFeedFormatter CreateFeed()
        {
            // Créez un flux RSS.
            SyndicationFeed feed = new SyndicationFeed("Bug Track", "Flux rss du bug track", null);
            List<SyndicationItem> items = new List<SyndicationItem>();

            // Créez un article RSS.
            List<DBO.Bug> bugs = DataAccess.Bug.GetLastBug(10);
            bugs.ForEach(bug => items.Add(new SyndicationItem(bug.Title, bug.Details, null)));

            feed.Items = items;

            // Renvoie ATOM ou RSS en fonction de la chaîne de requête
            // rss -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceBugTrack/Feed1/
            // atom -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceBugTrack/Feed1/?format=atom
            string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"];
            SyndicationFeedFormatter formatter = null;
            if (query == "atom")
            {
                formatter = new Atom10FeedFormatter(feed);
            }
            else
            {
                formatter = new Rss20FeedFormatter(feed);
            }

            return formatter;
        }
开发者ID:ThomasCOLLIN,项目名称:TPs,代码行数:28,代码来源:Feed1.cs

示例4: GetJobs

        public SyndicationFeedFormatter GetJobs(string format)
        {
            var groups = _Scheduler.GetJobGroupNames();
            SyndicationFeed feed = new SyndicationFeed();
            List<SyndicationItem> items = new List<SyndicationItem>();
            foreach (var group in groups)
            {
                var jobKeys = _Scheduler.GetJobKeys(GroupMatcher<JobKey>.GroupEquals(group));

                foreach (var jobKey in jobKeys)
                {
                    var job = _Scheduler.GetJobDetail(jobKey);
                    SyndicationItem item = new SyndicationItem();
                    item.Id = job.Key.ToString();
                    item.LastUpdatedTime = DateTime.UtcNow;
                    item.Title = new TextSyndicationContent(string.Format("{0} - {1}", job.Key.Group, job.Key.Name), TextSyndicationContentKind.Plaintext);
                    item.Summary = new TextSyndicationContent(string.Format("Job {0} for group {1}.", job.Key.Name, job.Key.Group), TextSyndicationContentKind.Plaintext);
                    items.Add(item);
                }

            }
            feed.Items = items;
            SyndicationFeedFormatter formatter = new Rss20FeedFormatter(feed);

            return formatter;
        }
开发者ID:GoneFishern,项目名称:QuartzNetFeaturePack,代码行数:26,代码来源:FeedService.cs

示例5: Index

        public async Task<ActionResult> Index()
        {
            var posts = await Task.Run(() => MvcApplication.Posts);
            var feed = new SyndicationFeed("invokecommand.net", "All blog posts", new Uri(this.ServerUrl("/rss.xml")), "1", DateTime.Now)
            {
                Items = posts.Select(
                    post => new SyndicationItem(
                        post.Title,
                        post.Summary,
                        new Uri(this.ServerUrl(post.Url.ToString())),
                        post.Name,
                        post.Published))
                    .ToList()
            };

            var formatter = new Rss20FeedFormatter(feed);
            var content = new StringBuilder();

            using (var writer = XmlWriter.Create(content))
            {
                formatter.WriteTo(writer);

                writer.Flush();
            }

            return Content(content.ToString(), "text/xml");
        }
开发者ID:pbering,项目名称:TinyBlogNet,代码行数:27,代码来源:RssController.cs

示例6: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            SyndicationFeedFormatter formatter;
            string contentType;

            switch (_feedType)
            {
                case FeedType.Atom:
                    formatter = new Atom10FeedFormatter(_syndicationFeed);
                    contentType = "application/atom+xml";
                    break;
                case FeedType.Rss:
                    formatter = new Rss20FeedFormatter(_syndicationFeed);
                    contentType = "application/rss+xml";
                    break;
                default:
                    throw new NotImplementedException("Feed type not accounted for");
            }

            context.HttpContext.Response.ContentType = contentType;

            using (var writer = XmlWriter.Create(context.HttpContext.Response.Output))
            {
                formatter.WriteTo(writer);
            }
        }
开发者ID:harpreet,项目名称:TinyBlog,代码行数:26,代码来源:FeedController.cs

示例7: Page_Load

        protected void Page_Load(object sender, System.EventArgs e)
        {
            List<SyndicationItem> syndicationItems = new List<SyndicationItem>();

            IList<Card> cards = uWiMP.TVServer.Cards.GetCards();
            foreach (Card card in cards)
            {
                if (card.Enabled & card.Name.ToLower().Contains("builtin"))
                {
                    uWiMP.TVServer.Cards.Status status = uWiMP.TVServer.Cards.GetCardStatus(card);
                    SyndicationItem si = new SyndicationItem();
                    si.Title = new TextSyndicationContent("Recording");
                }
            }

            SyndicationFeed feed = new SyndicationFeed(syndicationItems);

            StringWriter output = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(output);

            Rss20FeedFormatter f = new Rss20FeedFormatter(feed);
            f.WriteTo(writer);

            Context.Response.ContentType = "application/rss+xml";
            Context.Response.Write(output.ToString());
        }
开发者ID:rndthoughts,项目名称:ipimpplus,代码行数:26,代码来源:RSS.aspx.cs

示例8: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.ContentType = "application/atom+xml";
            //check request is for Atom or RSS
            if (context.HttpContext.Request.QueryString["type"] != null && context.HttpContext.Request.QueryString["type"].ToString().ToLower() == "atom")
            {
                //Atom Feed
                context.HttpContext.Response.ContentType = "application/atom+xml";
                var rssFormatter = new Atom10FeedFormatter(FeedData);
                using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output, new XmlWriterSettings { Indent = true }))
                {
                    rssFormatter.WriteTo(writer);
                }
            }
            else
            {
                //RSS Feed
                context.HttpContext.Response.ContentType = "application/rss+xml";
                var rssFormatter = new Rss20FeedFormatter(FeedData);
                using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output, new XmlWriterSettings { Indent = true }))
                {
                    rssFormatter.WriteTo(writer);
                }
            }

        }
开发者ID:smashmirrorcardboardface,项目名称:Azure-ServiceBus-Testing,代码行数:26,代码来源:FeedResult.cs

示例9: CreateFeed

        public SyndicationFeedFormatter CreateFeed()
        {
            // Create a new Syndication Feed.
            SyndicationFeed feed = new SyndicationFeed("Feed Title", "A WCF Syndication Feed", null);
            List<SyndicationItem> items = new List<SyndicationItem>();

            // Create a new Syndication Item.
            SyndicationItem item = new SyndicationItem("An item", "Item content", null);
            items.Add(item);
            feed.Items = items;

            // Return ATOM or RSS based on query string
            // rss -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/
            // atom -> http://localhost:8733/Design_Time_Addresses/SyndicationServiceLibrary1/Feed1/?format=atom
            string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"];
            SyndicationFeedFormatter formatter = null;
            if (query == "atom")
            {
                formatter = new Atom10FeedFormatter(feed);
            }
            else
            {
                formatter = new Rss20FeedFormatter(feed);
            }

            return formatter;
        }
开发者ID:hkuntal,项目名称:MySociety,代码行数:27,代码来源:Feed1.cs

示例10: getXmlContent

        private Action<Stream> getXmlContent(IEnumerable<BlogPost> model)
        {
            var items = model.Select(post =>
                new SyndicationItem(
                    title: post.Title,
                    content: post.Content,
                    itemAlternateLink: new Uri(BaseUrl + post.GetLink().TrimStart('/')),
                    id: post.Id,
                    lastUpdatedTime: post.PubDate)
                                                 {
                                                     PublishDate = post.PubDate,
                                                     Summary = new TextSyndicationContent(post.Content, TextSyndicationContentKind.Html)
                                                 })
                                                 .ToList();

            var feed = new SyndicationFeed(RssTitle, RssTitle, BaseUrl, items);

            var formatter = new Rss20FeedFormatter(feed);

            return stream =>
            {
                using (var writer = XmlWriter.Create(stream))
                {
                    formatter.WriteTo(writer);
                }
            };
        }
开发者ID:iloveyouzlw,项目名称:MZBlog,代码行数:27,代码来源:RssResponse.cs

示例11: ParseXml

        /// <summary>
        /// Wybiera stronę na podstawie adresu url i zapisuje wszystkie wiadomości w kolekcji
        /// </summary>
        /// <param name="lineNews">Lista wiadomości</param>
        /// <param name="category">Kategoria źródłowa do odczytu</param>
        public void ParseXml(ObservableCollection<News> lineNews, Category category)
        {
            try
            {
                using (XmlReader reader = XmlReader.Create(category.Url))
                {
                    var formatter = new Rss20FeedFormatter();
                    formatter.ReadFrom(reader);
                    foreach (var item in formatter.Feed.Items)
                    {
                        lineNews.Add(new News
                        {
                            Title = item.Title.Text,
                            Date = item.PublishDate.DateTime.ToString(),
                            UrlNews = item.Links.First().Uri.ToString(),
                            Description = item.Summary.Text,
                            Category = category.Name,
                            Id = item.Id
                        });

                        if (item.Links.Count > 1 && item.Links.Any(n => n.Uri.ToString().Contains(".jpg")))
                            lineNews.Last().UrlImage = item.Links[1].Uri.ToString();

                        ParseId(lineNews.Last());
                        ParseDescription(lineNews.Last());
                    }
                }
            }
            catch (WebException ex)
            {
                MessageBox.Show(ex.Message, "Syndication Reader");
            }
        }
开发者ID:mobile32,项目名称:RSS-Reader,代码行数:38,代码来源:Reader.cs

示例12: GetRssFeedItems

 public static List<SyndicationItem> GetRssFeedItems(string url)
 {
     Rss20FeedFormatter formatter = new Rss20FeedFormatter();
     XmlReader reader;
     try
     {
          reader = XmlReader.Create(url);
         formatter.ReadFrom(reader);
     }
     catch(XmlException xexp)
     {
         string xml;
         using (WebClient webClient = new WebClient())
         {
             xml = Encoding.UTF8.GetString(webClient.DownloadData(url));
         }
         xml = xml.Replace("BST", "+0100");
         xml = xml.Replace("GMT", "+0000");
         byte[] bytes = System.Text.UTF8Encoding.ASCII.GetBytes(xml);
         reader = XmlReader.Create(new MemoryStream(bytes));
         formatter.ReadFrom(reader);
     }
     reader.Close();
     return formatter.Feed == null ? null : formatter.Feed.Items.ToList();
 }
开发者ID:philwith,项目名称:racingresource,代码行数:25,代码来源:RssUtilities.cs

示例13: CreateFeed

        public SyndicationFeedFormatter CreateFeed()
        {
            string serverUrl = ConfigurationManager.AppSettings["CatMyVideoUrl"];
            // Create a new Syndication Feed.
            SyndicationFeed feed = new SyndicationFeed();

            feed.Id = "#CatMyVideo URL";

            List<SyndicationItem> items = new List<SyndicationItem>();

            feed.Title = new TextSyndicationContent("Last trends on CatMyVideo");
            feed.Description = new TextSyndicationContent(String.Format("Todays' top {0} hottest videos on CatMyVideo", MAXVIDEO));
            feed.Copyright = new TextSyndicationContent("Copy/Paste rights CatMyVideo");
            feed.Generator = "CatMyVideo RSS Feeder 1.0";
            feed.Authors.Add(new SyndicationPerson("[email protected]"));

            feed.LastUpdatedTime = new DateTimeOffset(DateTime.Now);

            var trendingVideos = Engine.BusinessManagement.Video.ListVideos(Engine.Dbo.Video.Order.UploadDate, false, MAXVIDEO, 0, true);
            for (int i = 0; i < trendingVideos.Count; i++)
            {
                SyndicationItem item = new SyndicationItem();

                string itemUrl = serverUrl + "/Video/Display/" + trendingVideos[i].Id;
                item.Id = itemUrl;

                var itemLink = new SyndicationLink(new Uri(itemUrl));
                itemLink.MediaType = "text/html";
                itemLink.Title = "Watch me !";
                item.Links.Add(itemLink);

                string htmlContent = String.Format("<!DOCTYPE html><html><head></head><body><h1>{0}</h1><p>{1}</p><a href=\"{2}\">Check this out !</a></body></html>",
                                                    trendingVideos[i].Title,
                                                    trendingVideos[i].Description,
                                                    itemUrl);
                TextSyndicationContent content = new TextSyndicationContent(htmlContent, TextSyndicationContentKind.Html);

                // Fill some properties for the item
                item.Title = new TextSyndicationContent("#" + (i + 1));
                item.LastUpdatedTime = DateTime.Now;
                item.PublishDate = trendingVideos[i].UploadDate;

                item.Content = content;
                items.Add(item);
            }
            feed.Items = items;

            string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"];
            SyndicationFeedFormatter formatter = null;
            if (query == "atom")
            {
                formatter = new Atom10FeedFormatter(feed);
            }
            else
            {
                formatter = new Rss20FeedFormatter(feed);
            }

            return formatter;
        }
开发者ID:Flasheur111,项目名称:CatMyVideo,代码行数:60,代码来源:CatMyVideoFeeder.cs

示例14: FilterFeed

 public Rss20FeedFormatter FilterFeed(Rss20FeedFormatter formatterFeed, IEnumerable<string> tags)
 {
     var feed = new SyndicationFeed() {Title = new TextSyndicationContent("Service Feed")};
     var result = new Rss20FeedFormatter(feed);
     result.Feed.Items = FilterItemsInFeedByTags(formatterFeed.Feed.Items, tags);
     return result;
 }
开发者ID:oleguchok,项目名称:SPP-Labs,代码行数:7,代码来源:FeedService.cs

示例15: fload

 public void fload(string namefile)
 {
         var lines = System.IO.File.ReadAllLines(namefile);
         feed.Title = new TextSyndicationContent(lines[1]);
         feed.Copyright = new TextSyndicationContent(lines[2]);
         feed.Description = new TextSyndicationContent(lines[3]);
         feed.Generator = lines[4];
         SyndicationLink link = new SyndicationLink();
         link.Uri = new Uri(lines[5]);
         feed.Links.Add(link);
         feed.Items = txtgotolv("feedinfo.txt");
         Response.Clear();
         Response.ContentEncoding = System.Text.Encoding.UTF8;
         Response.ContentType = "text/xml";
         XmlWriter Writer = XmlWriter.Create
         (Response.Output);
         if (lines[0] == "rss")
         {
             Rss20FeedFormatter Formatter = new Rss20FeedFormatter(feed);
             Formatter.WriteTo(Writer);
         }
         else
         {
             if (lines[0] == "atom")
             {
                 Atom10FeedFormatter Formatter = new Atom10FeedFormatter(feed);
                 Formatter.WriteTo(Writer);
             }
         }
         Writer.Close();
         Response.End();
 }
开发者ID:1342MPA,项目名称:CourseProject,代码行数:32,代码来源:Default.aspx.cs


注:本文中的System.ServiceModel.Syndication.Rss20FeedFormatter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。