當前位置: 首頁>>代碼示例>>C#>>正文


C# Atom10FeedFormatter.WriteTo方法代碼示例

本文整理匯總了C#中System.ServiceModel.Syndication.Atom10FeedFormatter.WriteTo方法的典型用法代碼示例。如果您正苦於以下問題:C# Atom10FeedFormatter.WriteTo方法的具體用法?C# Atom10FeedFormatter.WriteTo怎麽用?C# Atom10FeedFormatter.WriteTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ServiceModel.Syndication.Atom10FeedFormatter的用法示例。


在下文中一共展示了Atom10FeedFormatter.WriteTo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ExecuteResult

 public override void ExecuteResult(ControllerContext context)
 {
     context.HttpContext.Response.ContentType = "application/atom+xml";
     var formatter = new Atom10FeedFormatter(Feed);
     using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
         formatter.WriteTo(writer);
 }
開發者ID:lg31415,項目名稱:Graphite,代碼行數:7,代碼來源:RssResult.cs

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

示例3: Build

        public string Build(FeedData dataFeed, Uri baseUri)
        {
            var feed = new SyndicationFeed
            {
                Id = dataFeed.Id.ToString(),
                LastUpdatedTime = dataFeed.DateCreated,
                Items = dataFeed.Messages.Select(x => new SyndicationItem
                {
                    Content = new RawSyndicationContent(x.Body),
                    Id = x.Id.ToString(),
                    LastUpdatedTime = x.CreatedAt
                })
            };

            if (!string.IsNullOrEmpty(dataFeed.NextUri))
                feed.Links.Add(new SyndicationLink(new Uri(baseUri, dataFeed.NextUri), NextInArchiveRelationshipType,
                    "Next In Archive", ContentType, 0));

            if (!string.IsNullOrEmpty(dataFeed.PreviousUri))
                feed.Links.Add(new SyndicationLink(new Uri(baseUri, dataFeed.PreviousUri), PrevInArchiveRelationshipType,
                    "Previous In Archive", ContentType, 0));

            var formatter = new Atom10FeedFormatter(feed);

            var sw = new StringWriter();
            using (var writer = XmlWriter.Create(sw))
            {
                formatter.WriteTo(writer);
            }

            return sw.ToString();
        }
開發者ID:peterbeams,項目名稱:SimpleAtomPubSub,代碼行數:32,代碼來源:AtomFormatter.cs

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

示例5: WriteFile

 //var formatter = new Rss20FeedFormatter(feed);
 //    Atom10FeedFormatter formatter = new Atom10FeedFormatter(feed);
 //using (var writer = XmlWriter.Create(response.Output, new XmlWriterSettings { Indent = true }))
 //{
 //    formatter.WriteTo(writer);
 //}
 protected override void WriteFile(HttpResponseBase response)
 {
     Atom10FeedFormatter formatter = new Atom10FeedFormatter(_feed);
     using (XmlWriter writer = XmlWriter.Create(response.OutputStream, new XmlWriterSettings { Indent = true }))
     {
         formatter.WriteTo(writer);
     }
 }
開發者ID:saeedesmaeili,項目名稱:SimpleBlog,代碼行數:14,代碼來源:RssActionResult.cs

示例6: GetXmlContents

 private static Action<Stream> GetXmlContents(SyndicationFeed feed)
 {
     return stream =>
     {
         var writer = new XmlTextWriter(stream, Encoding.UTF8);
         var atomFormatter = new Atom10FeedFormatter(feed);
         atomFormatter.WriteTo(writer);
     };
 }
開發者ID:jstclair,項目名稱:Rosanna,代碼行數:9,代碼來源:AtomResponse.cs

示例7: OnWriteToStream

 public override void OnWriteToStream(Type type, object value, Stream stream, HttpContentHeaders contentHeaders, TransportContext context)
 {
     var formatter = new Atom10FeedFormatter((SyndicationFeed) value);
     using (var xmlWriter = XmlWriter.Create(stream))
     {
         formatter.WriteTo(xmlWriter);
         xmlWriter.Close();
     }
 }
開發者ID:ashic,項目名稱:Hermes,代碼行數:9,代碼來源:AtomMediaTypeFormatter.cs

示例8: CreateContentFromAtom10SyndicationFeed

 public static StreamContent CreateContentFromAtom10SyndicationFeed(SyndicationFeed feed)
 {
     SyndicationFeedFormatter formatter = new Atom10FeedFormatter<SyndicationFeed>(feed);
     var memoryStream = new MemoryStream();
     var settings = new XmlWriterSettings { Encoding = Encoding.UTF8, ConformanceLevel = ConformanceLevel.Document, Indent = true };
     using (var xmlWriter = XmlWriter.Create(memoryStream, settings))
     {
         formatter.WriteTo(xmlWriter);
         xmlWriter.Flush();
         xmlWriter.Close();
     }
     memoryStream.Seek(0, SeekOrigin.Begin);
     return new StreamContent(memoryStream);
 }
開發者ID:RaoulHolzer,項目名稱:EnergyTrading-MDM-Sample,代碼行數:14,代碼來源:HttpContentUtilities.cs

示例9: WriteFile

        protected override void WriteFile(HttpResponseBase response)
        {
            _isRssFeed = _feedType == FeedType.Rss;

            // Creates Xml file.
            string xmlFile = HttpContext.Current.Server.MapPath("~/feed.xml");
            using (var fileStream = new FileStream(xmlFile, FileMode.Create))
            {
                using (var streamWriter = new StreamWriter(fileStream, Encoding.UTF8))
                {
                    var xs = new XmlWriterSettings { Indent = true };
                    using (var xmlWriter = XmlWriter.Create(streamWriter, xs))
                    {
                        xmlWriter.WriteStartDocument();
                        if (_isCssStyles)
                        {
                            const string strPi = "type='text/css' href='/Contents/Styles/feedStyle.css'";
                            // Write processor information
                            xmlWriter.WriteProcessingInstruction("xml-stylesheet", strPi);
                        }
                        if (_isRssFeed)
                        {
                            // RSS 2.0
                            var rssFormatter = new Rss20FeedFormatter(_feed, true);
                            rssFormatter.WriteTo(xmlWriter);
                        }
                        else
                        {
                            // Atom 1.0
                            var atomFormatter = new Atom10FeedFormatter(_feed);
                            atomFormatter.WriteTo(xmlWriter);
                        }
                    }
                }
            }
            //Display Xml file in browser.
            response.Clear();
            response.Buffer = true;
            response.Charset = "";
            response.Cache.SetCacheability(HttpCacheability.NoCache);
            response.ContentType = "text/xml";
            response.WriteFile(HttpContext.Current.Server.MapPath("~/feed.xml"));
            response.Flush();
            response.End();
        }
開發者ID:rriwaj,項目名稱:rss-feed-wcf,代碼行數:45,代碼來源:RssResult.cs

示例10: ExecuteResult

        /// <summary>
        /// Executes the call to the ActionResult method and returns the created feed to the output response.
        /// </summary>
        /// <param name="context">The context in which the result is executed. The context information includes the 
        /// controller, HTTP content, request context, and route data.</param>
        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.ContentType = ContentType.Atom;
            var feedFormatter = new Atom10FeedFormatter(this._syndicationFeed);
            var xmlWriterSettings = new XmlWriterSettings {Encoding = Encoding.UTF8};

            if (HttpContext.Current.IsDebuggingEnabled)
            {
                // Indent the XML for easier viewing but only in Debug mode. In Release mode, everything is output on 
                // one line for best performance.
                xmlWriterSettings.Indent = true;
            }

            using (var xmlWriter = XmlWriter.Create(context.HttpContext.Response.Output, xmlWriterSettings))
            {
                feedFormatter.WriteTo(xmlWriter);
            }
        }
開發者ID:rabbal,項目名稱:Decision,代碼行數:23,代碼來源:AtomActionResult.cs

示例11: WriteFile

        protected override void WriteFile(HttpResponseBase response)
        {
            _isRssFeed = _feedType == FeedType.Rss;

            // Creates Xml file.
            string xmlFile = HttpContext.Current.Server.MapPath("~/feed.xml");
            using (var fileStream = new FileStream(xmlFile, FileMode.Create))
            {
                using (var streamWriter = new StreamWriter(fileStream, Encoding.UTF8))
                {
                    var xs = new XmlWriterSettings { Indent = true };
                    using (var xmlWriter = XmlWriter.Create(streamWriter, xs))
                    {
                        xmlWriter.WriteStartDocument();
                        if (_isRssFeed)
                        {
                            // RSS 2.0
                            var rssFormatter = new Rss20FeedFormatter(_feed);
                            rssFormatter.WriteTo(xmlWriter);
                        }
                        else
                        {
                            // Atom 1.0
                            var atomFormatter = new Atom10FeedFormatter(_feed);
                            atomFormatter.WriteTo(xmlWriter);
                        }
                    }
                }
            }
            XslTransform myXslTransform = new XslTransform();
            myXslTransform.Load(HttpContext.Current.Server.MapPath("~/feed.xslt"));
            myXslTransform.Transform(HttpContext.Current.Server.MapPath("~/feed.xml"), HttpContext.Current.Server.MapPath("~/newFeed.xml"));

            //Display Xml file in browser.
            response.Clear();
            response.Buffer = true;
            response.Charset = "";
            response.Cache.SetCacheability(HttpCacheability.NoCache);
            response.ContentType = "application/xml";
            response.WriteFile(HttpContext.Current.Server.MapPath("~/newFeed.xml"));
            response.Flush();
            response.End();
        }
開發者ID:rriwaj,項目名稱:rss-feed-wcf,代碼行數:43,代碼來源:RssResultXslt.cs

示例12: ExecuteResult

        /// <summary>
        /// Executes the call to the ActionResult method and returns the created feed to the output response.
        /// </summary>
        /// <param name="context">The context in which the result is executed. The context information includes the 
        /// controller, HTTP content, request context, and route data.</param>
        public override void ExecuteResult(ActionContext context)
        {
            context.HttpContext.Response.ContentType = ContentType.Atom;
            Atom10FeedFormatter feedFormatter = new Atom10FeedFormatter(this.syndicationFeed);
            XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
            xmlWriterSettings.Encoding = Encoding.UTF8;

            if (Context.Environment.IsDevelopment())
            {
                // Indent the XML for easier viewing but only in Debug mode. In Release mode, everything is output on 
                // one line for best performance.
                xmlWriterSettings.Indent = true;
            }

            using (XmlWriter xmlWriter = XmlWriter.Create(context.HttpContext.Response.Body, xmlWriterSettings))
            {
                feedFormatter.WriteTo(xmlWriter);
            }
        }
開發者ID:razormad,項目名稱:ASP.NET-MVC-Boilerplate,代碼行數:24,代碼來源:AtomActionResult.cs

示例13: Index

        public ActionResult Index()
        {
            var syndicationItems =
                this.DB.Themes.Select(ToSyndicationItem)
                .Concat(this.DB.Votes.Include("Theme").Select(ToSyndicationItem))
                .OrderByDescending(s => s.LastUpdatedTime);

            var feed = new SyndicationFeed(_Localize.SiteTitle, "", this.GetAppUrl(), syndicationItems.ToArray());
            var formatter = new Atom10FeedFormatter(feed);

            return new LamdaResult(context =>
            {
                var response = context.HttpContext.Response;
                response.ContentType = "application/xml";
                var xmlWriter = XmlWriter.Create(response.OutputStream);
                formatter.WriteTo(xmlWriter);
                xmlWriter.Flush();
            });
        }
開發者ID:naoki0311,項目名稱:teachmeteachyousurvey,代碼行數:19,代碼來源:RSSController.cs

示例14: try_it_out

        public void try_it_out()
        {
            var doc = new XmlDocument().WithRoot("root").WithAtt("a", "1");
            var feed = new SyndicationFeed("some feed", "cool feed", new Uri("http://elsewere.com"));

            var item = new SyndicationItem("the title", "some content", new Uri("http://somewhere.com"));
            item.ElementExtensions.Add(doc);

            feed.Items = new SyndicationItem[]{item};

            var builder = new StringBuilder();
            var writer = XmlWriter.Create(builder);
            var formatter = new Atom10FeedFormatter(feed);

            formatter.WriteTo(writer);
            writer.Close();

            Debug.WriteLine(builder);
        }
開發者ID:mmoore99,項目名稱:fubumvc,代碼行數:19,代碼來源:play.cs

示例15: ExecuteResult

 public override void ExecuteResult(ControllerContext context)
 {
     _isRssFeed = _feedType == FeedType.Rss;
     context.HttpContext.Response.ContentType = _isRssFeed
                 ? "application/rss+xml"
                 : "application/atom+xml";
     var writerSettings = new XmlWriterSettings { Indent = true };
     using (var feedWriter = XmlWriter.Create(context.HttpContext.Response.OutputStream, writerSettings))
     {
         if (_isRssFeed)
         {
             // RSS 2.0
             var rssFormatter = new Rss20FeedFormatter(_feed);
             rssFormatter.WriteTo(feedWriter);
         }
         else
         {
             var atomFormatter = new Atom10FeedFormatter(_feed);
             atomFormatter.WriteTo(feedWriter);
         }
     }
 }
開發者ID:rriwaj,項目名稱:rss-feed-wcf,代碼行數:22,代碼來源:RssActionResult.cs


注:本文中的System.ServiceModel.Syndication.Atom10FeedFormatter.WriteTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。