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


C# Engine.Execute方法代码示例

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


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

示例1: CompletedContentIsPopulatedAfterRun

        public void CompletedContentIsPopulatedAfterRun()
        {
            // Given
            Engine engine = new Engine();
            int c = 0;
            engine.Pipelines.Add(
                new Execute((x, ctx) => new[]
                {
                    x.Clone((c++).ToString()),
                    x.Clone((c++).ToString())
                }),
                new Execute((x, ctx) => new[]
                {
                    x.Clone((c++).ToString())
                }),
                new Meta("Content", (x, y) => x.Content));

            // When
            engine.Execute();

            // Then
            Assert.AreEqual(2, engine.Documents.FromPipeline("Pipeline 1").Count());
            Assert.AreEqual("2", engine.Documents.FromPipeline("Pipeline 1").First().String("Content"));
            Assert.AreEqual("3", engine.Documents.FromPipeline("Pipeline 1").Skip(1).First().String("Content"));
        }
开发者ID:JasonKoopmans,项目名称:Wyam,代码行数:25,代码来源:EngineFixture.cs

示例2: ExecuteAllExamples

 public void ExecuteAllExamples()
 {
     string path = Path.Combine(Assembly.GetExecutingAssembly().Location, "Examples");
     while (!Directory.Exists(path))
     {
         path = Directory.GetParent(path).Parent.FullName;
         path = Path.Combine(path, "Examples");
     }
     int count = 0;
     foreach(string example in Directory.EnumerateDirectories(path))
     {
         Console.WriteLine("Executing example " + example);
         Engine engine = new Engine
         {
             RootFolder = example
         };
         string config = Path.Combine(example, "config.wyam");
         if (File.Exists(config))
         {
             Console.WriteLine("Loading configuration file");
             engine.Configure(File.ReadAllText(config));
         }
         engine.Execute();
         count++;
     }
     Assert.AreEqual(4, count);
 }
开发者ID:Rohansi,项目名称:Wyam,代码行数:27,代码来源:ExamplesFixture.cs

示例3: CompletedContentIsPopulatedAfterRun

        public void CompletedContentIsPopulatedAfterRun()
        {
            // Given
            Engine engine = new Engine();
            engine.CleanOutputPathOnExecute = false;
            int c = 0;
            engine.Pipelines.Add(
                new Execute((x, ctx) => new[]
                {
                    ctx.GetDocument(x, (c++).ToString()),
                    ctx.GetDocument(x, (c++).ToString())
                }),
                new Execute((x, ctx) => new[]
                {
                    ctx.GetDocument(x, (c++).ToString())
                }),
                new Core.Modules.Metadata.Meta("Content", (x, y) => x.Content));

            // When
            engine.Execute();

            // Then
            Assert.AreEqual(2, engine.Documents.FromPipeline("Pipeline 1").Count());
            Assert.AreEqual("2", engine.Documents.FromPipeline("Pipeline 1").First().String("Content"));
            Assert.AreEqual("3", engine.Documents.FromPipeline("Pipeline 1").Skip(1).First().String("Content"));
        }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:26,代码来源:EngineTests.cs

示例4: ExecuteAllExamples

 public void ExecuteAllExamples(string example)
 {
     Engine engine = new Engine();
     engine.Trace.AddListener(new TestTraceListener());
     engine.RootFolder = example;
     engine.Config.Assemblies.LoadDirectory(TestContext.CurrentContext.TestDirectory);
     string config = Path.Combine(example, "config.wyam");
     if (File.Exists(config))
     {
         engine.Configure(File.ReadAllText(config));
     }
     engine.Execute();
 }
开发者ID:Chandu,项目名称:Wyam,代码行数:13,代码来源:ExamplesFixture.cs

示例5: ExecuteAllExamples

 public void ExecuteAllExamples(string example)
 {
     Engine engine = new Engine
     {
         RootFolder = example
     };
     engine.Trace.AddListener(new TestTraceListener());
     string config = Path.Combine(example, "config.wyam");
     if (File.Exists(config))
     {
         engine.Configure(File.ReadAllText(config));
     }
     engine.Execute();
 }
开发者ID:martinvobr,项目名称:Wyam,代码行数:14,代码来源:ExamplesFixture.cs

示例6: IgnoresUnderscoresByDefault

        public void IgnoresUnderscoresByDefault()
        {
            // Given
            Engine engine = new Engine();
            engine.InputFolder = @"TestFiles\Input\";
            ReadFiles readFiles = new ReadFiles(@"IgnoreUnderscores\*.cshtml");
            Razor razor = new Razor();
            engine.Pipelines.Add("Pipeline", readFiles, razor);

            // When
            engine.Execute();

            // Then
            Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Count());
            Assert.AreEqual("LAYOUT\r\n\r\n<p>This is a test</p>", engine.Documents.FromPipeline("Pipeline").First().Content);
        }
开发者ID:Rohansi,项目名称:Wyam,代码行数:16,代码来源:RazorFixture.cs

示例7: AlternateViewStartPath

        public void AlternateViewStartPath()
        {
            // Given
            Engine engine = new Engine();
            engine.InputFolder = @"TestFiles\Input\";
            ReadFiles readFiles = new ReadFiles(@"AlternateViewStartPath\Test.cshtml");
            Razor razor = new Razor().SetViewStart(@"AlternateViewStart\_ViewStart.cshtml");
            engine.Pipelines.Add("Pipeline", readFiles, razor);

            // When
            engine.Execute();

            // Then
            Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Count());
            Assert.AreEqual("LAYOUT\r\n<p>This is a test</p>", engine.Documents.FromPipeline("Pipeline").First().Content);
        }
开发者ID:Rohansi,项目名称:Wyam,代码行数:16,代码来源:RazorFixture.cs

示例8: AlternateIgnorePrefix

        public void AlternateIgnorePrefix()
        {
            // Given
            Engine engine = new Engine();
            engine.InputFolder = @"TestFiles\Input\";
            ReadFiles readFiles = new ReadFiles(@"AlternateIgnorePrefix\*.cshtml");
            Razor razor = new Razor().IgnorePrefix("Ignore");
            engine.Pipelines.Add("Pipeline", readFiles, razor);

            // When
            engine.Execute();

            // Then
            Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Count());
            Assert.AreEqual(@"<p>This is a test</p>", engine.Documents.FromPipeline("Pipeline").First().Content);
        }
开发者ID:Rohansi,项目名称:Wyam,代码行数:16,代码来源:RazorFixture.cs

示例9: LoadSimpleTemplateFile

        public void LoadSimpleTemplateFile()
        {
            // Given
            Engine engine = new Engine();
            engine.InputFolder = @"TestFiles\Input\";
            ReadFiles readFiles = new ReadFiles(@"SimpleTemplate\Test.cshtml");
            Razor razor = new Razor();
            engine.Pipelines.Add("Pipeline", readFiles, razor);

            // When
            engine.Execute();

            // Then
            Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Count());
            Assert.AreEqual(@"<p>This is a test</p>", engine.Documents.FromPipeline("Pipeline").First().Content);
        }
开发者ID:tareq-s,项目名称:Wyam,代码行数:16,代码来源:RazorFixture.cs

示例10: AlternateViewStartPath

            public void AlternateViewStartPath()
            {
                // Given
                Engine engine = new Engine();
                engine.RootFolder = TestContext.CurrentContext.TestDirectory;
                engine.InputFolder = @"TestFiles\Input\";
                ReadFiles readFiles = new ReadFiles(@"AlternateViewStartPath\Test.cshtml");
                Razor razor = new Razor().WithViewStart(@"AlternateViewStart\_ViewStart.cshtml");
                Meta meta = new Meta("Content", (x, y) => x.Content);
                engine.Pipelines.Add("Pipeline", readFiles, razor, meta);

                // When
                engine.Execute();

                // Then
                Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Count());
                Assert.AreEqual("LAYOUT\r\n<p>This is a test</p>", engine.Documents.FromPipeline("Pipeline").First().String("Content"));
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:18,代码来源:RazorTests.cs

示例11: CompletedMetadataIsPopulatedAfterRun

        public void CompletedMetadataIsPopulatedAfterRun()
        {
            // Given
            Engine engine = new Engine();
            engine.CleanOutputPathOnExecute = false;
            int c = 0;
            engine.Pipelines.Add("Pipeline",
                new Execute((x, ctx) => new[]
                {
                    ctx.GetDocument(x, (string)null, new Dictionary<string, object> { { c.ToString(), c++ } }),
                    ctx.GetDocument(x, (string)null, new Dictionary<string, object> { { c.ToString(), c++ } })
                }),
                new Execute((x, ctx) => new[]
                {
                    ctx.GetDocument(x, (string)null, new Dictionary<string, object> { { c.ToString(), c++ } })
                }));

            // When
            engine.Execute();

            // Then
            Assert.AreEqual(2, engine.Documents.FromPipeline("Pipeline").Count());

            Assert.IsTrue(engine.Documents.FromPipeline("Pipeline").First().Metadata.ContainsKey("0"));
            Assert.AreEqual(0, engine.Documents.FromPipeline("Pipeline").First().Metadata["0"]);
            Assert.IsTrue(engine.Documents.FromPipeline("Pipeline").First().Metadata.ContainsKey("2"));
            Assert.AreEqual(2, engine.Documents.FromPipeline("Pipeline").First().Metadata["2"]);
            Assert.IsFalse(engine.Documents.FromPipeline("Pipeline").First().Metadata.ContainsKey("1"));
            Assert.IsFalse(engine.Documents.FromPipeline("Pipeline").First().Metadata.ContainsKey("3"));

            Assert.IsTrue(engine.Documents.FromPipeline("Pipeline").Skip(1).First().Metadata.ContainsKey("1"));
            Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Skip(1).First().Metadata["1"]);
            Assert.IsTrue(engine.Documents.FromPipeline("Pipeline").Skip(1).First().Metadata.ContainsKey("3"));
            Assert.AreEqual(3, engine.Documents.FromPipeline("Pipeline").Skip(1).First().Metadata["3"]);
            Assert.IsFalse(engine.Documents.FromPipeline("Pipeline").Skip(1).First().Metadata.ContainsKey("0"));
            Assert.IsFalse(engine.Documents.FromPipeline("Pipeline").Skip(1).First().Metadata.ContainsKey("2"));
        }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:37,代码来源:EngineTests.cs

示例12: RenderLayoutSectionOnMultipleExecution

            public void RenderLayoutSectionOnMultipleExecution()
            {
                // Given
                Engine engine = new Engine();
                engine.RootFolder = TestContext.CurrentContext.TestDirectory;
                engine.InputFolder = @"TestFiles\Input\";
                ReadFiles readFiles = new ReadFiles(@"LayoutWithSection\Test.cshtml");
                Razor razor = new Razor();
                Meta meta = new Meta("Content", (x, y) => x.Content);
                engine.Pipelines.Add("Pipeline", readFiles, razor, meta);

                // When
                engine.Execute();
                engine.Execute();

                // Then
                Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Count());
                Assert.AreEqual("LAYOUT\r\n\r\n<p>Section Content</p>\r\n\r\n\r\n<p>This is a test</p>", engine.Documents.FromPipeline("Pipeline").First().String("Content"));
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:19,代码来源:RazorTests.cs

示例13: LoadSimpleTemplateFile

            public void LoadSimpleTemplateFile()
            {
                // Given
                Engine engine = new Engine();
                engine.RootFolder = TestContext.CurrentContext.TestDirectory;
                engine.InputFolder = @"TestFiles\Input\";
                ReadFiles readFiles = new ReadFiles(@"SimpleTemplate\Test.cshtml");
                Razor razor = new Razor();
                Meta meta = new Meta("Content", (x, y) => x.Content);
                engine.Pipelines.Add("Pipeline", readFiles, razor, meta);

                // When
                engine.Execute();

                // Then
                Assert.AreEqual(1, engine.Documents.FromPipeline("Pipeline").Count());
                Assert.AreEqual(@"<p>This is a test</p>", engine.Documents.FromPipeline("Pipeline").First().String("Content"));
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:18,代码来源:RazorTests.cs

示例14: Execute

        private bool Execute(Engine engine)
        {
            try
            {
                engine.Execute();
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:13,代码来源:Program.cs

示例15: Execute

        private bool Execute(Engine engine)
        {
            try
            {
                engine.Execute();
            }
            catch (Exception ex)
            {
                engine.Trace.Critical("Error while executing: {0}", ex.Message);
                return false;
            }

            return true;
        }
开发者ID:Chandu,项目名称:Wyam,代码行数:14,代码来源:Program.cs


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