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


C# Engine.Configure方法代码示例

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


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

示例1: Tracing

        public void Tracing()
        {
            // Given
            string inputFolder = Path.Combine(Environment.CurrentDirectory, @".\Input");
            if (!Directory.Exists(inputFolder))
            {
                Directory.CreateDirectory(inputFolder);
            }
            ITrace trace = Substitute.For<ITrace>();
            IExecutionContext context = Substitute.For<IExecutionContext>();
            context.RootFolder.Returns(Environment.CurrentDirectory);
            context.InputFolder.Returns(inputFolder);
            context.Trace.Returns(trace);
            Engine engine = new Engine();
            engine.Configure();
            context.Assemblies.Returns(engine.Assemblies);
            IDocument document = Substitute.For<IDocument>();
            document.GetStream().Returns(new MemoryStream(Encoding.UTF8.GetBytes(@"@{ ExecutionContext.Trace.Information(""Test""); }")));
            Razor razor = new Razor();

            // When
            razor.Execute(new[] { document }, context).ToList();  // Make sure to materialize the result list

            // Then
            ITrace receivedTrace = context.Received().Trace; // Need to assign to dummy var to keep compiler happy
            trace.Received().Information("Test");
        }
开发者ID:martinvobr,项目名称:Wyam,代码行数:27,代码来源:RazorFixture.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: SimpleTemplate

        public void SimpleTemplate()
        {
            // Given
            string inputFolder = Path.Combine(Environment.CurrentDirectory, @".\Input");
            if (!Directory.Exists(inputFolder))
            {
                Directory.CreateDirectory(inputFolder);
            }
            IExecutionContext context = Substitute.For<IExecutionContext>();
            context.RootFolder.Returns(Environment.CurrentDirectory);
            context.InputFolder.Returns(inputFolder);
            Engine engine = new Engine();
            engine.Configure();
            context.Assemblies.Returns(engine.Assemblies);
            IDocument document = Substitute.For<IDocument>();
            document.GetStream().Returns(new MemoryStream(Encoding.UTF8.GetBytes(@"@for(int c = 0 ; c < 5 ; c++) { <p>@c</p> }")));
            Razor razor = new Razor();

            // When
            razor.Execute(new[] { document }, context).ToList();  // Make sure to materialize the result list

            // Then
            document.Received(1).Clone(Arg.Any<string>());
            document.Received().Clone(" <p>0</p>  <p>1</p>  <p>2</p>  <p>3</p>  <p>4</p> ");
        }
开发者ID:martinvobr,项目名称:Wyam,代码行数:25,代码来源:RazorFixture.cs

示例4: Configure

        private bool Configure(Engine engine)
        {
            try
            {
                // If we have a configuration file use it, otherwise configure with defaults
                IFile configFile = engine.FileSystem.GetRootFile(_configFilePath);
                if (configFile.Exists)
                {
                    Trace.Information("Loading configuration from {0}", configFile.Path);
                    engine.Configure(configFile, _updatePackages, _outputScripts);
                }
                else
                {
                    Trace.Information("Could not find configuration file {0}, using default configuration", _configFilePath);
                    engine.Configure(GetDefaultConfigScript(), _updatePackages);
                }
            }
            catch (Exception ex)
            {
                Trace.Critical("Error while loading configuration: {0}", ex.Message);
                return false;
            }

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

示例5: 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

示例6: 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

示例7: Configure

        private bool Configure(Engine engine)
        {
            try
            {
                // If we have a configuration file use it, otherwise configure with defaults
                if (File.Exists(_configFile))
                {
                    engine.Trace.Information("Loading configuration from {0}", _configFile);
                    engine.Configure(Wyam.Common.IO.SafeIOHelper.ReadAllText(_configFile), _updatePackages, Path.GetFileName(_configFile), _outputScripts);
                }
                else
                {
                    engine.Trace.Information("Could not find configuration file {0}, using default configuration", _configFile);
                    engine.Configure(GetDefaultConfigScript(), _updatePackages, null, _outputScripts);
                }
            }
            catch (Exception ex)
            {
                engine.Trace.Critical("Error while loading configuration: {0}", ex.Message);
                return false;
            }

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

示例8: ConfigureSupportsGlobalConstructorMethods

        public void ConfigureSupportsGlobalConstructorMethods()
        {
            // Given
            Engine engine = new Engine();
            string configScript = @"
                Pipelines.Add(
                    ReadFiles(""*.cshtml""),
	                WriteFiles("".html""));
            ";

            // When
            engine.Configure(configScript);

            // Then
            Assert.AreEqual(1, ((PipelineCollection)engine.Pipelines).Pipelines.Count());
            Assert.AreEqual(2, ((PipelineCollection)engine.Pipelines).Pipelines.First().Count);
        }
开发者ID:martinvobr,项目名称:Wyam,代码行数:17,代码来源:EngineFixture.cs

示例9: ConfigureAddsPipelineAndModules

        public void ConfigureAddsPipelineAndModules()
        {
            // Given
            Engine engine = new Engine();
            string configScript = @"
                Pipelines.Add(
                    new ReadFiles(""*.cshtml""),
	                new WriteFiles("".html""));
            ";

            // When
            engine.Configure(configScript);

            // Then
            Assert.AreEqual(1, ((PipelineCollection)engine.Pipelines).Pipelines.Count());
            Assert.AreEqual(2, ((PipelineCollection)engine.Pipelines).Pipelines.First().Count);
        }
开发者ID:martinvobr,项目名称:Wyam,代码行数:17,代码来源:EngineFixture.cs

示例10: ConfigureSetsPrimitiveMetadata

        public void ConfigureSetsPrimitiveMetadata()
        {
            // Given
            Engine engine = new Engine();
            string configScript = @"
                Metadata[""TestString""] = ""teststring"";
                Metadata[""TestInt""] = 1234;
                Metadata[""TestFloat""] = 1234.567;
                Metadata[""TestBool""] = true;
            ";

            // When
            engine.Configure(configScript);

            // Then
            Assert.AreEqual("teststring", engine.Metadata["TestString"]);
            Assert.AreEqual(1234, engine.Metadata["TestInt"]);
            Assert.AreEqual(1234.567, engine.Metadata["TestFloat"]);
            Assert.AreEqual(true, engine.Metadata["TestBool"]);
        }
开发者ID:martinvobr,项目名称:Wyam,代码行数:20,代码来源:EngineFixture.cs

示例11: Document

            public void Document()
            {
                // Given
                string inputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @".\Input");
                if (!Directory.Exists(inputFolder))
                {
                    Directory.CreateDirectory(inputFolder);
                }
                IExecutionContext context = Substitute.For<IExecutionContext>();
                context.RootFolder.Returns(TestContext.CurrentContext.TestDirectory);
                context.InputFolder.Returns(inputFolder);
                Engine engine = new Engine();
                engine.Configure();
                context.Assemblies.Returns(engine.Assemblies);
                IDocument document = Substitute.For<IDocument>();
                document.Source.Returns(@"C:\Temp\temp.txt");
                document.GetStream().Returns(new MemoryStream(Encoding.UTF8.GetBytes(@"<p>@Document.Source</p>")));
                Razor razor = new Razor();

                // When
                razor.Execute(new[] { document }, context).ToList();

                // Then
                context.Received(1).GetDocument(Arg.Any<IDocument>(), Arg.Any<string>());
                context.Received().GetDocument(document, @"<p>C:\Temp\temp.txt</p>");
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:26,代码来源:RazorTests.cs

示例12: Tracing

            public void Tracing()
            {
                // Given
                string inputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @".\Input");
                if (!Directory.Exists(inputFolder))
                {
                    Directory.CreateDirectory(inputFolder);
                }
                IExecutionContext context = Substitute.For<IExecutionContext>();
                context.RootFolder.Returns(TestContext.CurrentContext.TestDirectory);
                context.InputFolder.Returns(inputFolder);
                Engine engine = new Engine();
                engine.Configure();
                context.Assemblies.Returns(engine.Assemblies);
                context.Namespaces.Returns(engine.Namespaces);
                IDocument document = Substitute.For<IDocument>();
                TraceListener traceListener = new TraceListener();
                Trace.AddListener(traceListener);
                document.GetStream().Returns(new MemoryStream(Encoding.UTF8.GetBytes(@"@{ Trace.Information(""Test""); }")));
                Razor razor = new Razor();

                // When
                razor.Execute(new[] { document }, context).ToList();  // Make sure to materialize the result list

                // Then
                Trace.RemoveListener(traceListener);
                CollectionAssert.Contains(traceListener.Messages, "Test");
            }
开发者ID:ryanrousseau,项目名称:Wyam,代码行数:28,代码来源:RazorTests.cs

示例13: Metadata

        public void Metadata()
        {
            // Given
            string inputFolder = Path.Combine(Environment.CurrentDirectory, @".\Input");
            if (!Directory.Exists(inputFolder))
            {
                Directory.CreateDirectory(inputFolder);
            }
            IExecutionContext context = Substitute.For<IExecutionContext>();
            context.RootFolder.Returns(Environment.CurrentDirectory);
            context.InputFolder.Returns(inputFolder);
            Engine engine = new Engine();
            engine.Configure();
            context.Assemblies.Returns(engine.Assemblies);
            IDocument document = Substitute.For<IDocument>();
            document.Metadata["MyKey"].Returns("MyValue");
            document.GetStream().Returns(new MemoryStream(Encoding.UTF8.GetBytes(@"<p>@Metadata[""MyKey""]</p>")));
            Razor razor = new Razor();

            // When
            razor.Execute(new[] { document }, context).ToList();

            // Then
            document.Received(1).Clone(Arg.Any<string>());
            document.Received().Clone("<p>MyValue</p>");
        }
开发者ID:st1pps,项目名称:Wyam,代码行数:26,代码来源:RazorFixture.cs

示例14: SimpleTemplate

        public void SimpleTemplate()
        {
            // Given
            string inputFolder = Path.Combine(Environment.CurrentDirectory, @".\Input");
            if (!Directory.Exists(inputFolder))
            {
                Directory.CreateDirectory(inputFolder);
            }
            IExecutionContext context = Substitute.For<IExecutionContext>();
            context.RootFolder.Returns(Environment.CurrentDirectory);
            context.InputFolder.Returns(inputFolder);
            Engine engine = new Engine();
            engine.Configure();
            context.Assemblies.Returns(engine.Assemblies);
            IDocument document = Substitute.For<IDocument>();
            document.Metadata.Get("SourceFileBase", "/").Returns("/");
            List<string> items = new List<string>();
            document
                .When(x => x.Clone(Arg.Any<string>()))
                .Do(x => items.Add(x.Arg<string>()));
            document.Content.Returns(@"@for(int c = 0 ; c < 5 ; c++) { <p>@c</p> }");
            Razor razor = new Razor();

            // When
            razor.Execute(new[] { document }, context).ToList();  // Make sure to materialize the result list

            // Then
            document.Received().Clone(Arg.Any<string>());
            Assert.AreEqual(1, items.Count());
            Assert.AreEqual(" <p>0</p>  <p>1</p>  <p>2</p>  <p>3</p>  <p>4</p> ", items.First());
        }
开发者ID:Rohansi,项目名称:Wyam,代码行数:31,代码来源:RazorFixture.cs

示例15: Metadata

        public void Metadata()
        {
            // Given
            string inputFolder = Path.Combine(Environment.CurrentDirectory, @".\Input");
            if (!Directory.Exists(inputFolder))
            {
                Directory.CreateDirectory(inputFolder);
            }
            IExecutionContext context = Substitute.For<IExecutionContext>();
            context.RootFolder.Returns(Environment.CurrentDirectory);
            context.InputFolder.Returns(inputFolder);
            Engine engine = new Engine();
            engine.Configure();
            context.Assemblies.Returns(engine.Assemblies);
            IDocument document = Substitute.For<IDocument>();
            document.Metadata.Get("SourceFileBase", "/").Returns("/");
            document.Metadata["MyKey"].Returns("MyValue");
            List<string> items = new List<string>();
            document
                .When(x => x.Clone(Arg.Any<string>()))
                .Do(x => items.Add(x.Arg<string>()));
            document.Content.Returns(@"<p>@Metadata[""MyKey""]</p>");
            Razor razor = new Razor();

            // When
            razor.Execute(new[] { document }, context).ToList();

            // Then
            document.Received().Clone(Arg.Any<string>());
            Assert.AreEqual(1, items.Count());
            Assert.AreEqual("<p>MyValue</p>", items.First());
        }
开发者ID:Rohansi,项目名称:Wyam,代码行数:32,代码来源:RazorFixture.cs


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