本文整理汇总了C#中Wyam.Core.Engine类的典型用法代码示例。如果您正苦于以下问题:C# Engine类的具体用法?C# Engine怎么用?C# Engine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Engine类属于Wyam.Core命名空间,在下文中一共展示了Engine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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
示例2: 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
示例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: ExecuteResultsInCorrectCounts
public void ExecuteResultsInCorrectCounts()
{
// Given
Engine engine = new Engine();
CountModule a = new CountModule("A")
{
AdditionalOutputs = 1
};
CountModule b = new CountModule("B")
{
AdditionalOutputs = 2
};
CountModule c = new CountModule("C")
{
AdditionalOutputs = 3
};
engine.Pipelines.Add(a, b, c);
// When
engine.Execute();
// Then
Assert.AreEqual(1, a.ExecuteCount);
Assert.AreEqual(1, b.ExecuteCount);
Assert.AreEqual(1, c.ExecuteCount);
Assert.AreEqual(1, a.InputCount);
Assert.AreEqual(2, b.InputCount);
Assert.AreEqual(6, c.InputCount);
Assert.AreEqual(2, a.OutputCount);
Assert.AreEqual(6, b.OutputCount);
Assert.AreEqual(24, c.OutputCount);
}
开发者ID:martinvobr,项目名称:Wyam,代码行数:32,代码来源:EngineFixture.cs
示例5: Execute
private bool Execute(Engine engine)
{
if (!_noClean)
{
try
{
engine.Trace.Information("Cleaning output directory {0}...", engine.OutputFolder);
if (Directory.Exists(engine.OutputFolder))
{
Directory.Delete(engine.OutputFolder, true);
}
engine.Trace.Information("Cleaned output directory.");
}
catch (Exception ex)
{
engine.Trace.Critical("Error while cleaning output directory: {0}.", ex.Message);
return false;
}
}
try
{
engine.Execute();
}
catch (Exception ex)
{
engine.Trace.Critical("Error while executing: {0}.", ex.Message);
return false;
}
return true;
}
开发者ID:tareq-s,项目名称:Wyam,代码行数:32,代码来源:Program.cs
示例6: 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
示例7: ToLookupOfStringReturnsCorrectLookup
public void ToLookupOfStringReturnsCorrectLookup()
{
// Given
Engine engine = new Engine();
Pipeline pipeline = new Pipeline("Pipeline", engine, null);
IDocument a = new Document(engine, pipeline)
.Clone("a", new[] { new KeyValuePair<string, object>("Numbers", new[] { 1, 2, 3 }) });
IDocument b = new Document(engine, pipeline)
.Clone("b", new[] { new KeyValuePair<string, object>("Numbers", new[] { 2, 3, 4 }) });
IDocument c = new Document(engine, pipeline)
.Clone("c", new[] { new KeyValuePair<string, object>("Numbers", 3) });
IDocument d = new Document(engine, pipeline)
.Clone("d", new[] { new KeyValuePair<string, object>("Numbers", "4") });
List<IDocument> documents = new List<IDocument>() { a, b, c, d };
// When
ILookup<string, IDocument> lookup = documents.ToLookup<string>("Numbers");
// Then
Assert.AreEqual(4, lookup.Count);
CollectionAssert.AreEquivalent(new[] { a }, lookup["1"]);
CollectionAssert.AreEquivalent(new[] { a, b }, lookup["2"]);
CollectionAssert.AreEquivalent(new[] { a, b, c }, lookup["3"]);
CollectionAssert.AreEquivalent(new[] { b, d }, lookup["4"]);
}
开发者ID:Chandu,项目名称:Wyam,代码行数:25,代码来源:DocumentCollectionExtensionsFixture.cs
示例8: 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
示例9: 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
示例10: 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
示例11: CanCloneWithNewValues
public void CanCloneWithNewValues()
{
// Given
Engine engine = new Engine();
Metadata metadata = new Metadata(engine);
// When
metadata = metadata.Clone(new [] { new KeyValuePair<string, object>("A", "a") });
// Then
Assert.AreEqual("a", metadata["A"]);
}
开发者ID:Rohansi,项目名称:Wyam,代码行数:12,代码来源:MetadataFixture.cs
示例12: ClonedMetadataDoesNotContainNewValues
public void ClonedMetadataDoesNotContainNewValues()
{
// Given
Engine engine = new Engine();
engine.Metadata["A"] = "a";
Metadata metadata = new Metadata(engine);
// When
Metadata clone = metadata.Clone(new Dictionary<string, object> { { "B", "b" } });
// Then
Assert.IsFalse(metadata.ContainsKey("B"));
}
开发者ID:Rohansi,项目名称:Wyam,代码行数:13,代码来源:MetadataFixture.cs
示例13: CloneContainsPreviousValues
public void CloneContainsPreviousValues()
{
// Given
Engine engine = new Engine();
engine.Metadata["A"] = "a";
Metadata metadata = new Metadata(engine);
// When
Metadata clone = metadata.Clone(new Dictionary<string, object> { { "B", "b" } });
// Then
Assert.AreEqual("a", clone["A"]);
}
开发者ID:Rohansi,项目名称:Wyam,代码行数:13,代码来源:MetadataFixture.cs
示例14: 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
示例15: CloneContainsNewValues
public void CloneContainsNewValues()
{
// Given
Engine engine = new Engine();
engine.Trace.AddListener(new TestTraceListener());
engine.Metadata["A"] = "a";
Metadata metadata = new Metadata(engine);
// When
Metadata clone = metadata.Clone(new Dictionary<string, object> { { "B", "b" } });
// Then
Assert.AreEqual("b", clone["B"]);
}
开发者ID:st1pps,项目名称:Wyam,代码行数:14,代码来源:MetadataFixture.cs
示例16: CloneReplacesValue
public void CloneReplacesValue()
{
// Given
Engine engine = new Engine();
engine.Metadata["A"] = "a";
Metadata metadata = new Metadata(engine);
// When
Metadata clone = metadata.Clone(new Dictionary<string, object> { { "A", "b" } });
// Then
Assert.AreEqual("a", metadata["A"]);
Assert.AreEqual("b", clone["A"]);
}
开发者ID:Rohansi,项目名称:Wyam,代码行数:14,代码来源:MetadataFixture.cs
示例17: ContainsKeyReturnsTrueForValidValue
public void ContainsKeyReturnsTrueForValidValue()
{
// Given
Engine engine = new Engine();
engine.Trace.AddListener(new TestTraceListener());
engine.Metadata["A"] = "a";
Metadata metadata = new Metadata(engine);
// When
bool contains = metadata.ContainsKey("A");
// Then
Assert.IsTrue(contains);
}
开发者ID:Chandu,项目名称:Wyam,代码行数:14,代码来源:MetadataFixture.cs
示例18: 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
示例19: IndexerNullKeyThrowsKeyNotFoundException
public void IndexerNullKeyThrowsKeyNotFoundException()
{
// Given
Engine engine = new Engine();
engine.Trace.AddListener(new TestTraceListener());
Metadata metadata = new Metadata(engine);
// When
TestDelegate test = () =>
{
object value = metadata[null];
};
// Then
Assert.Throws<ArgumentNullException>(test);
}
开发者ID:Chandu,项目名称:Wyam,代码行数:16,代码来源:MetadataFixture.cs
示例20: 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
注:本文中的Wyam.Core.Engine类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论