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


C# Rss20FeedFormatter.WriteTo方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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:SK-Marten,项目名称:SimpleCQRS,代码行数:35,代码来源:RSSResult.cs

示例8: WriteFile

		protected override void WriteFile(HttpResponseBase response)
		{
			var rssFormatter = new Rss20FeedFormatter(Feed);

			using (var writer = XmlWriter.Create(response.Output))
				rssFormatter.WriteTo(writer);

			response.End();
		}
开发者ID:NovusCraft,项目名称:NovusCraft,代码行数:9,代码来源:RssResult.cs

示例9: ExecuteResult

 public override void ExecuteResult(ControllerContext context)
 {
     context.HttpContext.Response.ContentType = "application/rss+xml";
     Rss20FeedFormatter formatter = new Rss20FeedFormatter(this.Feed);
     using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
     {
         formatter.WriteTo(writer);
     }
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:9,代码来源:RssActionResult.cs

示例10: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.ContentType = MimeTypes.ApplicationRssXml;

            var rssFormatter = new Rss20FeedFormatter(Feed);
            using (var writer = XmlWriter.Create(context.HttpContext.Response.Output))
            {
                rssFormatter.WriteTo(writer);
            }
        }
开发者ID:nvolpe,项目名称:raver,代码行数:10,代码来源:RssActionResult.cs

示例11: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.ContentType = Constants.RssContentType;

            Rss20FeedFormatter rss = new Rss20FeedFormatter(Feed);
            using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
            {
                rss.WriteTo(writer);
            }
        }
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:10,代码来源:RssActionResult.cs

示例12: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.ContentType = "application/rss+xml";

            var rssFormatter = new Rss20FeedFormatter(_feed, false);
            using (var writer = XmlWriter.Create(context.HttpContext.Response.Output, new XmlWriterSettings { Indent = true }))
            {
                rssFormatter.WriteTo(writer);
            }
        }
开发者ID:ytechie,项目名称:SimpleTracking,代码行数:10,代码来源:RssActionResult.cs

示例13: ExecuteResult

 public override void ExecuteResult(ControllerContext context)
 {
     var response = context.HttpContext.Response;
     response.ContentType = "application/rss+xml";
     var rssFormatter = new Rss20FeedFormatter(Feed);
     using (var writer = XmlWriter.Create(response.Output))
     {
         // Feed là nguồn dữ liệu. Thao tác ở đây là lấy nguồn dữ liệu Feed ghi ra response dưới dạng RSS
         rssFormatter.WriteTo(writer);
     }
 }
开发者ID:sounj142,项目名称:aaabbb,代码行数:11,代码来源:RssActionResult.cs

示例14: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.ContentType = "application/rss+xml";

            var feed = new SyndicationFeed(Title, Description, Link);
            var formatter = new Rss20FeedFormatter();

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

示例15: ExecuteResult

        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.ContentType = "application/rss+xml";

            if (Feed == null) throw new ArgumentNullException("Feed");

            var formater = new Rss20FeedFormatter(Feed);
            using (var writer = XmlWriter.Create(context.HttpContext.Response.Output))
            {
                formater.WriteTo(writer);
            }
        }
开发者ID:rallysportphoto,项目名称:Portal,代码行数:12,代码来源:RssResult.cs


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