示例#1
1
        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");
        }
示例#2
0
        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);
                }
            };
        }
示例#3
0
        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);
            }
        }
示例#4
0
 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();
 }
        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);
                }
            }

        }
示例#6
0
        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());
        }
示例#7
0
        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);
            }

        }
示例#8
0
		protected override void WriteFile(HttpResponseBase response)
		{
			var rssFormatter = new Rss20FeedFormatter(Feed);

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

			response.End();
		}
示例#9
0
 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);
     }
 }
示例#10
0
        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);
            }
        }
示例#11
0
        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);
            }
        }
示例#12
0
        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);
            }
        }
示例#13
0
 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);
     }
 }
示例#14
0
        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);
            }
        }
示例#15
0
        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);
            }
        }
示例#16
0
        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.ContentType = "application/rss+xml";

            var rssFormatter = new Rss20FeedFormatter(Feed, false);
            var settings = new XmlWriterSettings { Indent = true, IndentChars = "\t", CheckCharacters = false };

            using (var writer = XmlWriter.Create(context.HttpContext.Response.Output, settings))
            {
                rssFormatter.WriteTo(writer);
            }
        }
示例#17
0
        public override async Task Invoke(IOwinContext context)
        {
            PathString subPath;
            context.Request.Path.StartsWithSegments(options.Path, out subPath);
            if (!subPath.StartsWithSegments(new PathString("/rss")))
            {
                await Next.Invoke(context);
                return;
            }

            const int pageSize = 15;
            var errorLogEntries = await errorLog.GetErrorsAsync(0, pageSize);

            var syndicationFeed = new SyndicationFeed();

            var hostName = EnvironmentUtilities.GetMachineNameOrDefault("Unknown Host");
            syndicationFeed.Title = new TextSyndicationContent($"Error log of {errorLog.ApplicationName} on {hostName}.");
            syndicationFeed.Description = new TextSyndicationContent("Log of recent errors");
            syndicationFeed.Language = "en-us";

            var uriAsString = context.Request.Uri.ToString();
            var baseUri = new Uri(uriAsString.Remove(uriAsString.LastIndexOf("/rss", StringComparison.InvariantCulture)));
            syndicationFeed.Links.Add(SyndicationLink.CreateAlternateLink(baseUri));

            var items = new List<SyndicationItem>();
            foreach (var errorLogEntry in errorLogEntries)
            {
                var item = new SyndicationItem
                {
                    Title = SyndicationContent.CreatePlaintextContent(errorLogEntry.Error.Message),
                    Content =
                        SyndicationContent.CreatePlaintextContent(
                            $"An error of type {errorLogEntry.Error.TypeName} occurred. {errorLogEntry.Error.Message}"),
                    PublishDate = errorLogEntry.Error.Time
                };
                item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(baseUri, $"/detail?id={errorLogEntry.Id}")));

                items.Add(item);
            }

            syndicationFeed.Items = items;

            context.Response.ContentType = "application/rss+xml";
            context.Response.StatusCode = 200;

            using (var writer = XmlWriter.Create(context.Response.Body, SettingsUtility.XmlWriterSettings))
            {
                var formatter = new Rss20FeedFormatter(syndicationFeed);
                formatter.WriteTo(writer);
            }
        }
        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.ContentType = "application/rss+xml";

            if (Feed != null)
            {
                var rssFormatter = new Rss20FeedFormatter(Feed);

                using (var xmlWriter = new XmlTextWriter(context.HttpContext.Response.Output))
                {
                    xmlWriter.Formatting = Formatting.Indented;
                    rssFormatter.WriteTo(xmlWriter);
                }
            }
        }
示例#19
0
        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            context.HttpContext.Response.ContentType = "text/xml";

            if (Feed != null)
                using (var rssWriter = new XmlTextWriter(context.HttpContext.Response.Output))
                {
                    rssWriter.Formatting = Formatting.Indented;
                    Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(Feed);
                    rssFormatter.WriteTo(rssWriter);
                }
        }
        public void ProcessRequest(HttpContext context)
        {
            var syndicationService = Ioc.Resolve<ISyndicationService>();
            SyndicationFeed feed = syndicationService.GetFeed();

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

            var feedWritter = new Rss20FeedFormatter(feed);
            feedWritter.WriteTo(writer);

            context.Response.ContentType = "application/rss_xml";
            context.Response.AppendHeader("Content-Disposition", "inline; filename=rss.xml");
            context.Response.Write(output.ToString());
        }
示例#21
0
        private Action<Stream> GetXmlContents(IEnumerable<BlogPost> model)
        {
            var items = new List<SyndicationItem>();

            foreach (var post in model)
            {
                // Replace all relative urls with full urls.
                var contentHtml = Regex.Replace(post.Content, UrlRegex, m => siteUrl.TrimEnd('/') + "/" + m.Value.TrimStart('/'));
                var excerptHtml = Regex.Replace(post.Summary, UrlRegex, m => siteUrl.TrimEnd('/') + "/" + m.Value.TrimStart('/'));

                var item = new SyndicationItem(
                    post.Title,
                    contentHtml,
                    new Uri(siteUrl + post.Localink)
                    )
                {
                    Id = siteUrl + post.Localink,
                    LastUpdatedTime = post.PublishedDate.ToUniversalTime(),
                    PublishDate = post.PublishedDate.ToUniversalTime(),
                    Content = new TextSyndicationContent(contentHtml, TextSyndicationContentKind.Html),
                    Summary = new TextSyndicationContent(excerptHtml, TextSyndicationContentKind.Html),

                };
                item.Authors.Add(new SyndicationPerson(post.AuthorEmail, post.Author, string.Empty));
                item.Categories.Add(new SyndicationCategory("nancy"));

                items.Add(item);
            }

            var feed = new SyndicationFeed(
                RssTitle,
                RssTitle, /* Using Title also as Description */
                new Uri(siteUrl + "/" + feedfileName),
                items);

            var formatter = new Rss20FeedFormatter(feed);

            return stream =>
            {
                var encoding = new UTF8Encoding(false);
                var streamWrapper = new UnclosableStreamWrapper(stream);

                using (var writer = new XmlTextWriter(streamWrapper, encoding))
                {
                    formatter.WriteTo(writer);
                }
            };
        }
示例#22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SyndicationFeed feed = Feeds.GetPostFeed();

            Response.Clear();
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType = "text/xml";

            using (XmlWriter rssWriter = XmlWriter.Create(Response.Output))
            {
                Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(feed);
                rssFormatter.WriteTo(rssWriter);
            }

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

            if (Feed != null)
            {
                var rssFormatter = new Rss20FeedFormatter(Feed);
                //remove a10 - http://stackoverflow.com/a/15971300/18475

                using (var xmlWriter = new XmlTextWriter(context.HttpContext.Response.Output))
                {
                    xmlWriter.Formatting = Formatting.Indented;
                    rssFormatter.WriteTo(xmlWriter);
                }
            }
        }
示例#24
0
        public override void ExecuteResult(ControllerContext context)
        {
            context.HttpContext.Response.ContentType = "application/rss+xml";

            if (p_Feed != null)
            {
                Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(p_Feed);
                using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))
                {
                    rssFormatter.WriteTo(writer);
                }
            }
            else
            {
                throw new Exception("Feed is null");
            }
        }
示例#25
0
        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();
        }
示例#26
0
        public ActionResult Feed()
        {
            StringBuilder output = new StringBuilder();
            var feedWriter = XmlWriter.Create(output);

            var metaData = PostMetaData.LoadPostMetaData(Server.MapPath("~/PostMetaData"));

            Rss20FeedFormatter rssFormatter = new Rss20FeedFormatter(RssSyndicator.GetFeed(metaData));
            rssFormatter.WriteTo(feedWriter);
            feedWriter.Close();

            return new ContentResult
            {
                Content = output.ToString().Replace("utf-16", "utf-8"),
                //ContentType = "application/rss+xml"
            };

            //return View();
        }
示例#27
0
        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();
        }
示例#28
0
        private Action<Stream> GetXmlContents(IEnumerable<BlogPost> model)
        {
            var items = new List<SyndicationItem>();
            var areaRoutePrefix = BlogUrl.ToString();

            foreach (var post in model)
            {
                var postUrl = post.ToUrl(areaRoutePrefix);
                var contentString = post.CompiledContent(true).ToHtmlString();

                var item = new SyndicationItem(
                    title: post.Title,
                    content: contentString,
                    itemAlternateLink: new Uri(BlogUrl, postUrl)
                    )
                               {
                                   PublishDate = post.PublishedAt.UtcDateTime,
                                   Summary = new TextSyndicationContent(contentString, TextSyndicationContentKind.XHtml),
                                   LastUpdatedTime = post.LastEditedAt == null ? post.PublishedAt.UtcDateTime : post.LastEditedAt.Value,
                                   // TODO authors
                               };
                items.Add(item);
            }

            var feed = new SyndicationFeed(
                blogConfig.BlogTitle,
                blogConfig.BlogDescription,
                BlogUrl,
                items)
                           {
                               Copyright = new TextSyndicationContent(blogConfig.CopyrightString, TextSyndicationContentKind.Plaintext),
                               Generator = "NSemble blog module",
                           };

            var formatter = new Rss20FeedFormatter(feed);
            return stream =>
            {
                using (XmlWriter writer = XmlWriter.Create(stream))
                {
                    formatter.WriteTo(writer);
                }
            };
        }
示例#29
0
        private Action<Stream> GetXmlContents(IEnumerable<Post> model)
        {
            var items = new List<SyndicationItem>();

            foreach (var post in model)
            {
                // Replace all relative urls with full urls.
                var newHtml = Regex.Replace(post.Content, UrlRegex, m => siteUrl.TrimEnd('/') + "/" + m.Value.TrimStart('/'));

                var item = new SyndicationItem(
                    post.Title,
                    newHtml,
                    new Uri(siteUrl + post.Url)
                    )
                {
                    Id = siteUrl + post.Url,
                    LastUpdatedTime = post.Date.ToUniversalTime(),
                    PublishDate = post.Date.ToUniversalTime(),
                    Summary = new TextSyndicationContent(post.ContentExcerpt, TextSyndicationContentKind.Html)
                };

                items.Add(item);
            }

            var feed = new SyndicationFeed(
                RssTitle,
                RssTitle, /* Using Title also as Description */
                new Uri(siteUrl + "/" + feedfileName),
                items);

            var formatter = new Rss20FeedFormatter(feed);

            return stream =>
            {
                var encoding = new UTF8Encoding(false);
                var streamWrapper = new UnclosableStreamWrapper(stream);

                using (var writer = new XmlTextWriter(streamWrapper, encoding))
                {
                    formatter.WriteTo(writer);
                }
            };
        }
示例#30
0
        private Action<Stream> GetXmlContents(IEnumerable<Post> model)
        {
            var items = new List<SyndicationItem>();

            foreach (Post post in model)
            {

                var item = new SyndicationItem(
                    title: post.Title,
                    content: post.Content,
                    itemAlternateLink: new Uri(siteUrl + post.Url),
                    id: siteUrl + post.Url,
                    lastUpdatedTime: post.Date.ToUniversalTime()
                    );
                item.PublishDate = post.Date.ToUniversalTime();
                item.Summary = new TextSyndicationContent(post.ContentExcerpt, TextSyndicationContentKind.Html);
                items.Add(item);
            }

            var feed = new SyndicationFeed(
                this.RssTitle,
                this.RssTitle, /* Using Title also as Description */
                new Uri(siteUrl + "/" + feedfileName),
                items);

            var formatter = new Rss20FeedFormatter(feed);

            return stream =>
            {
                var encoding =
                    new UTF8Encoding(false);

                var streamWrapper =
                    new UnclosableStreamWrapper(stream);

                using (var writer = new XmlTextWriter(streamWrapper, encoding))
                {
                    formatter.WriteTo(writer);
                }
            };
        }