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


C# Pipelines.Pipeline类代码示例

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


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

示例1: DefaultCtorIgnoresDelimiterOnFirstLine

            public void DefaultCtorIgnoresDelimiterOnFirstLine()
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs =
                {
                    context.GetDocument(@"---
                FM1
                FM2
                ---
                Content1
                Content2")
                };
                string frontMatterContent = null;
                FrontMatter frontMatter = new FrontMatter(new Execute((x, ctx) =>
                {
                    frontMatterContent = x.Content;
                    return new[] {x};
                }));

                // When
                IEnumerable<IDocument> documents = frontMatter.Execute(inputs, context);

                // Then
                Assert.AreEqual(1, documents.Count());
                Assert.AreEqual(@"FM1
                FM2
                ", frontMatterContent);
                Assert.AreEqual(@"Content1
                Content2", documents.First().Content);
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:33,代码来源:FrontMatterTests.cs

示例2: DefaultCtorSplitsAtDashes

        public void DefaultCtorSplitsAtDashes()
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            IDocument[] inputs = { new Document(engine, pipeline).Clone(@"FM1
            FM2
            ---
            Content1
            Content2") };
            string frontMatterContent = null;
            FrontMatter frontMatter = new FrontMatter(new Execute((x, ctx) =>
            {
                frontMatterContent = x.Content;
                return new [] {x};
            }));

            // When
            IEnumerable<IDocument> documents = frontMatter.Execute(inputs, context);

            // Then
            Assert.AreEqual(1, documents.Count());
            Assert.AreEqual(@"FM1
            FM2
            ", frontMatterContent);
            Assert.AreEqual(@"Content1
            Content2", documents.First().Content);
        }
开发者ID:st1pps,项目名称:Wyam,代码行数:30,代码来源:FrontMatterFixture.cs

示例3: CopyWithSearchPatternRecursive

        public void CopyWithSearchPatternRecursive()
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            engine.RootFolder = TestContext.CurrentContext.TestDirectory;
            engine.InputFolder= @"TestFiles\Input\";
            engine.OutputFolder = @"TestFiles\Output\";

            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IDocument[] inputs = { new Document(engine, pipeline).Clone("Test") };
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            CopyFiles copyFiles = new CopyFiles("*.txt");

            // When
            IEnumerable<IDocument> outputs = copyFiles.Execute(inputs, context).ToList();
            foreach (IDocument document in inputs.Concat(outputs))
            {
                ((IDisposable)document).Dispose();
            }

            // Then
            Assert.IsTrue(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\test-a.txt")));
            Assert.IsTrue(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\test-b.txt")));
            Assert.IsTrue(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\Subfolder\test-c.txt")));
            Assert.IsFalse(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\markdown-x.md")));
            Assert.IsFalse(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\Subfolder\markdown-y.md")));
        }
开发者ID:Chandu,项目名称:Wyam,代码行数:28,代码来源:CopyFilesFixture.cs

示例4: CopyFolderFromAboveInputPath

            public void CopyFolderFromAboveInputPath()
            {
                // Given
                Engine engine = new Engine();
                engine.RootFolder = TestContext.CurrentContext.TestDirectory;
                engine.InputFolder = @"TestFiles\Input\";
                engine.OutputFolder = @"TestFiles\Output\";
                engine.CleanOutputPath();

                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument("Test") };
                CopyFiles copyFiles = new CopyFiles("../*.txt").FromTopDirectoryOnly();

                // When
                IEnumerable<IDocument> outputs = copyFiles.Execute(inputs, context).ToList();
                foreach (IDocument document in inputs.Concat(outputs))
                {
                    ((IDisposable) document).Dispose();
                }

                // Then
                Assert.IsFalse(
                    File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\test-a.txt")));
                Assert.IsFalse(
                    File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestFiles\Output\test-b.txt")));
                Assert.IsFalse(
                    File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory,
                        @"TestFiles\Output\Subfolder\test-c.txt")));
                Assert.IsTrue(
                    File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory,
                        @"TestFiles\Output\test-above-input.txt")));
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:33,代码来源:CopyFilesTests.cs

示例5: DashStringDoesNotSplitAtNonmatchingDashes

        public void DashStringDoesNotSplitAtNonmatchingDashes()
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            IDocument[] inputs = { new Document(engine, pipeline).Clone(@"FM1
            FM2
            ---
            Content1
            Content2") };
            bool executed = false;
            FrontMatter frontMatter = new FrontMatter("-", new Execute((x, ctx) =>
            {
                executed = true;
                return new[] { x };
            }));

            // When
            IEnumerable<IDocument> documents = frontMatter.Execute(inputs, context);

            // Then
            Assert.AreEqual(1, documents.Count());
            Assert.IsFalse(executed);
            Assert.AreEqual(@"FM1
            FM2
            ---
            Content1
            Content2", documents.First().Content);
        }
开发者ID:st1pps,项目名称:Wyam,代码行数:31,代码来源:FrontMatterFixture.cs

示例6: SitemapGeneratedWithSitemapItem

        public void SitemapGeneratedWithSitemapItem(string hostname, string formatterString, string expected)
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());

            if (!string.IsNullOrWhiteSpace(hostname))
                engine.Metadata[Keys.Hostname] = hostname;

            Pipeline contentPipeline = new Pipeline("Content", engine, null);
            var doc = new Document(engine, contentPipeline).Clone("Test", new[] { new KeyValuePair<string, object>(Keys.RelativeFilePath, "sub/testfile.html") });
            IDocument[] inputs = { doc };

            IExecutionContext context = new ExecutionContext(engine, contentPipeline);
            Core.Modules.Metadata.Meta m = new Core.Modules.Metadata.Meta(Keys.SitemapItem, (d, c) => new SitemapItem(d[Keys.RelativeFilePath].ToString()));
            var outputs = m.Execute(inputs, context);

            Func<string, string> formatter = null;

            if (!string.IsNullOrWhiteSpace(formatterString))
                formatter = f => string.Format(formatterString, f);

            // When
            Sitemap sitemap = new Sitemap(formatter);
            List<IDocument> results = sitemap.Execute(outputs.ToList(), context).ToList();

            foreach (IDocument document in inputs.Concat(outputs.ToList()))
            {
                ((IDisposable)document).Dispose();
            }

            // Then
            Assert.AreEqual(1, results.Count);
            Assert.That(results[0].Content, Does.Contain($"<loc>{expected}</loc>"));
        }
开发者ID:Chandu,项目名称:Wyam,代码行数:35,代码来源:SitemapFixture.cs

示例7: Add

 public IPipeline Add(string name, bool processDocumentsOnce, params IModule[] modules)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         name = "Pipeline " + (_pipelines.Count + 1);
     }
     if (_pipelines.ContainsKey(name))
     {
         throw new ArgumentException("Pipelines must have a unique name.");
     }
     Pipeline pipeline = new Pipeline(name, processDocumentsOnce, _engine, modules);
     _pipelines.Add(name, pipeline);
     return pipeline;
 }
开发者ID:martinvobr,项目名称:Wyam,代码行数:14,代码来源:PipelineCollection.cs

示例8: ExecuteGetsCorrectContent

            public void ExecuteGetsCorrectContent()
            {
                // Given
                Engine engine = new Engine();
                engine.RootFolder = TestContext.CurrentContext.TestDirectory;
                engine.InputFolder = @"TestFiles\Input";
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument() };
                ReadFiles readFiles = new ReadFiles(@"test-a.txt");

                // When
                IDocument document = readFiles.Execute(inputs, context).First();

                // Then
                Assert.AreEqual("aaa", document.Content);
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:17,代码来源:ReadFilesTests.cs

示例9: ExecuteGetsCorrectContent

        public void ExecuteGetsCorrectContent()
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            engine.InputFolder = @"TestFiles\Input";
            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IDocument[] inputs = { new Document(engine, pipeline) };
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            ReadFiles readFiles = new ReadFiles(@"test-a.txt");

            // When
            IDocument document = readFiles.Execute(inputs, context).First();

            // Then
            Assert.AreEqual("aaa", document.Content);
        }
开发者ID:st1pps,项目名称:Wyam,代码行数:17,代码来源:ReadFilesFixture.cs

示例10: ReadFilesSetsMetadata

        public void ReadFilesSetsMetadata(string key, string expectedEnding)
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            engine.InputFolder = @"TestFiles\Input";
            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IDocument[] inputs = { new Document(engine, pipeline) };
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            ReadFiles readFiles = new ReadFiles(@"test-c.txt");

            // When
            IDocument document = readFiles.Execute(inputs, context).First();

            // Then
            Assert.That(document.Metadata[key], Is.StringEnding(expectedEnding));
        }
开发者ID:st1pps,项目名称:Wyam,代码行数:17,代码来源:ReadFilesFixture.cs

示例11: FileNameIsConvertedCorrectly

            public void FileNameIsConvertedCorrectly(string input, string output)
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument(new MetadataItems
                {
                    new MetadataItem(Keys.SourceFileName, input)
                }) };
                FileName fileName = new FileName();

                // When
                IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

                // Then
                Assert.AreEqual(output, documents.First()[Keys.WriteFileName]);
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:18,代码来源:FileNameTests.cs

示例12: SearchPatternWorksWithoutInputPathTrailingSlash

        public void SearchPatternWorksWithoutInputPathTrailingSlash()
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            engine.InputFolder = @"TestFiles\Input";
            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IDocument[] inputs = { new Document(engine, pipeline) };
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            ReadFiles readFiles = new ReadFiles("*.txt");

            // When
            IEnumerable<IDocument> documents = readFiles.Execute(inputs, context);
            int count = documents.Count();
            
            // Then
            Assert.AreEqual(3, count);
        }
开发者ID:martinvobr,项目名称:Wyam,代码行数:18,代码来源:ReadFilesFixture.cs

示例13: SearchPatternFindsCorrectFiles

        public void SearchPatternFindsCorrectFiles(string searchPattern, SearchOption searchOption, int expectedCount)
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            engine.InputFolder = @"TestFiles\Input\";
            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IDocument[] inputs = { new Document(engine, pipeline) };
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            ReadFiles readFiles = new ReadFiles(searchPattern).WithSearchOption(searchOption);

            // When
            IEnumerable<IDocument> documents = readFiles.Execute(inputs, context);
            int count = documents.Count();
            
            // Then
            Assert.AreEqual(expectedCount, count);
        }
开发者ID:martinvobr,项目名称:Wyam,代码行数:18,代码来源:ReadFilesFixture.cs

示例14: FileNameIsConvertedCorrectly

        public void FileNameIsConvertedCorrectly(string input, string output)
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            IDocument[] inputs = { new Document(engine, pipeline).Clone(new []
            {
                Common.Documents.Metadata.Create("SourceFileName", input)
            }) };
            FileName fileName = new FileName();

            // When
            IEnumerable<IDocument> documents = fileName.Execute(inputs, context);

            // Then
            Assert.AreEqual(output, documents.First()["WriteFileName"]);
        }
开发者ID:st1pps,项目名称:Wyam,代码行数:19,代码来源:FileNameFixture.cs

示例15: StreamIsDisposedCorrectlyAfterClone

        public void StreamIsDisposedCorrectlyAfterClone()
        {
            // Given
            Engine engine = new Engine();
            Pipeline pipeline = new Pipeline("Test", engine, Array.Empty<IModule>());
            DisposeCheckStream stream = new DisposeCheckStream();
            Document originalDoc = new Document(engine, pipeline, "Test", stream, null, Array.Empty<KeyValuePair<string, object>>(), true);
            Document clonedDoc = (Document)originalDoc.Clone(Array.Empty<KeyValuePair<string, object>>());

            // When
            originalDoc.Dispose();
            bool originalDocDisposedStream = stream.Disposed;
            clonedDoc.Dispose();
            bool clonedDocDisposedStream = stream.Disposed;

            // Then
            Assert.AreEqual(false, originalDocDisposedStream);
            Assert.AreEqual(true, clonedDocDisposedStream);
        }
开发者ID:martinvobr,项目名称:Wyam,代码行数:19,代码来源:DocumentFixture.cs


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