Ejemplo n.º 1
0
        private IDocument GenerateFeed(FeedType feedType, Feed feed, ContextConfig path, IExecutionContext context)
        {
            // Get the output path
            FilePath outputPath = path?.Invoke <FilePath>(context, "while getting output path");

            if (outputPath == null)
            {
                return(null);
            }
            if (!outputPath.IsRelative)
            {
                throw new ArgumentException("The feed output path must be relative");
            }

            // Generate the feed and document
            MemoryStream stream = new MemoryStream();

            FeedSerializer.SerializeXml(feedType, feed, stream);
            stream.Position = 0;
            return(context.GetDocument(stream, new MetadataItems
            {
                new MetadataItem(Keys.RelativeFilePath, outputPath),
                new MetadataItem(Keys.WritePath, outputPath)
            }));
        }
        private async Task <IDocument> GenerateFeedAsync(FeedType feedType, Feed feed, FilePath path, IExecutionContext context)
        {
            // Get the output path
            if (path == null)
            {
                return(null);
            }
            if (!path.IsRelative)
            {
                throw new ArgumentException("The feed output path must be relative");
            }

            // Generate the feed and document
            using (Stream contentStream = await context.GetContentStreamAsync())
            {
                FeedSerializer.SerializeXml(feedType, feed, contentStream);
                return(context.CreateDocument(path, context.GetContentProvider(contentStream)));
            }
        }