本文整理汇总了C#中Workspace.Compile方法的典型用法代码示例。如果您正苦于以下问题:C# Workspace.Compile方法的具体用法?C# Workspace.Compile怎么用?C# Workspace.Compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Workspace
的用法示例。
在下文中一共展示了Workspace.Compile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldCreateTasks
public void ShouldCreateTasks()
{
Task.Tasks.Clear();
var workspace = new Workspace();
workspace.BasePath = Path.Combine(basePath, "ShouldCreateTasks");
Directory.CreateDirectory(workspace.TasksDir);
var f = File.Create(Path.Combine(workspace.TasksDir, "task1.crake"));
var buf = ASCIIEncoding.ASCII.GetBytes("namespace :name1 do\ntask :todo1 do\nint i;\nSay();\nSay();\nend\nend\n public void Say() {\nConsole.WriteLine(\"oi\");\n}");
f.Write(buf, 0, buf.Length);
f.Close();
workspace.LoadFiles();
workspace.Parse();
workspace.Compile();
var linker = new Linker(workspace);
Assert.AreEqual(0, Task.Tasks.Count);
linker.CreateTasks();
Assert.AreEqual(1, Task.Tasks.Count);
Task.Tasks["name1:todo1"].Run();
}
示例2: ShouldCompileNLines
public void ShouldCompileNLines()
{
var workspace = new Workspace();
workspace.BasePath = Path.Combine(basePath, "Compile");
Directory.CreateDirectory(workspace.TasksDir);
var f = File.Create(Path.Combine(workspace.TasksDir, "task1.crake"));
var buf = ASCIIEncoding.ASCII.GetBytes("namespace :name1 do\ntask :todo1 do\nint i;\nSay();\nSay();\nend\nend\n public void Say() {\nConsole.WriteLine(\"oi\");\n}");
f.Write(buf, 0, buf.Length);
f.Close();
workspace.LoadFiles();
workspace.Parse();
workspace.Compile();
var typeName = string.Format("Crake.Runtime.{0}", workspace.ParsedFiles[0].UniqueName);
Type type = null;
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (var asm in loadedAssemblies) {
type = asm.GetType(typeName);
if (type != null) break;
}
Assert.IsNotNull(Assembly.GetAssembly(type));
}