• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Pipelines.Pipeline类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ExecuteReturnsSameContent

            public void ExecuteReturnsSameContent()
            {
                // Given
                Engine engine = new Engine();
                engine.OutputFolder = @"TestFiles\Output\";
                engine.InitialMetadata[Keys.SourceFileRoot] = @"TestFiles/Input";
                engine.InitialMetadata[Keys.SourceFileDir] = @"TestFiles/Input/Subfolder";
                engine.InitialMetadata[Keys.SourceFileBase] = @"write-test";
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                IDocument[] inputs = { context.GetDocument("Test") };
                WriteFiles writeFiles = new WriteFiles((x, y) => null);

                // When
                IDocument output = writeFiles.Execute(inputs, context).First();

                // Then
                Assert.AreEqual("Test", output.Content);
                ((IDisposable)output).Dispose();
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:20,代码来源:WriteFilesTests.cs


示例17: FileNameIsConvertedCorrectlyWithReservedChar

            public void FileNameIsConvertedCorrectlyWithReservedChar(string character)
            {
                // Given
                Engine engine = new Engine();
                Pipeline pipeline = new Pipeline("Pipeline", null);
                IExecutionContext context = new ExecutionContext(engine, pipeline);
                string manyCharactersWow = new String(character[0], 10);
                IDocument[] inputs = { context.GetDocument(new MetadataItems
                {
                    new MetadataItem(Keys.SourceFileName,
                        string.Format("testing {0} some of {0} these {0}", manyCharactersWow))
                }) };
                FileName fileName = new FileName();

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

                // Then
                Assert.AreEqual("testing-some-of-these-", documents.First()[Keys.WriteFileName]);
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:20,代码来源:FileNameTests.cs


示例18: ExecuteReturnsSameContent

        public void ExecuteReturnsSameContent()
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            engine.OutputFolder = @"TestFiles\Output\";
            engine.Metadata["SourceFileRoot"] = @"TestFiles/Input";
            engine.Metadata["SourceFileDir"] = @"TestFiles/Input/Subfolder";
            engine.Metadata["SourceFileBase"] = @"write-test";
            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IDocument[] inputs = { new Document(engine, pipeline).Clone("Test") };
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            WriteFiles writeFiles = new WriteFiles((x, y) => null);

            // When
            IDocument output = writeFiles.Execute(inputs, context).First();

            // Then
            Assert.AreEqual("Test", output.Content);
            ((IDisposable)output).Dispose();
        }
开发者ID:st1pps,项目名称:Wyam,代码行数:21,代码来源:WriteFilesFixture.cs


示例19: FileNameIsConvertedCorrectlyWithReservedChar

        public void FileNameIsConvertedCorrectlyWithReservedChar(string character)
        {
            // Given
            Engine engine = new Engine();
            engine.Trace.AddListener(new TestTraceListener());
            Pipeline pipeline = new Pipeline("Pipeline", engine, null);
            IExecutionContext context = new ExecutionContext(engine, pipeline);
            string manyCharactersWow = new String(character[0], 10);
            IDocument[] inputs = { new Document(engine, pipeline).Clone(new []
            {
                Common.Documents.Metadata.Create("SourceFileName",
                    string.Format("testing {0} some of {0} these {0}", manyCharactersWow))
            }) };
            FileName fileName = new FileName();

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

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


示例20: FileNameShouldBeLowercase

		public void FileNameShouldBeLowercase()
		{
			// Given
			string input = "FileName With MiXeD CapS";
			string output = "filename-with-mixed-caps";

            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 []
			{
                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:Chandu,项目名称:Wyam,代码行数:22,代码来源:FileNameFixture.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IO.DJsIO类代码示例发布时间:2022-05-26
下一篇:
C# Core.Engine类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap