本文整理汇总了C#中Antlr4.StringTemplate.TemplateGroupFile.Unload方法的典型用法代码示例。如果您正苦于以下问题:C# TemplateGroupFile.Unload方法的具体用法?C# TemplateGroupFile.Unload怎么用?C# TemplateGroupFile.Unload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Antlr4.StringTemplate.TemplateGroupFile
的用法示例。
在下文中一共展示了TemplateGroupFile.Unload方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestUnloadWithImports
public void TestUnloadWithImports()
{
writeFile(tmpdir, "t.stg",
"import \"g1.stg\"\n\nmain() ::= <<\nv1-<f()>\n>>");
writeFile(tmpdir, "g1.stg", "f() ::= \"g1\"");
writeFile(tmpdir, "g2.stg", "f() ::= \"g2\"\nf2() ::= \"f2\"\n");
TemplateGroup group = new TemplateGroupFile(Path.Combine(tmpdir, "t.stg"));
Template st = group.GetInstanceOf("main");
Assert.AreEqual("v1-g1", st.Render());
// Change the text of group t, including the imports.
writeFile(tmpdir, "t.stg", "import \"g2.stg\"\n\nmain() ::= <<\nv2-<f()>;<f2()>\n>>");
group.Unload();
st = group.GetInstanceOf("main");
Assert.AreEqual("v2-g2;f2", st.Render());
}
示例2: TestUnloadImportedTemplatedSpecifiedInGroupFile
public void TestUnloadImportedTemplatedSpecifiedInGroupFile()
{
writeFile(tmpdir, "t.stg",
"import \"g1.stg\"\n\nmain() ::= <<\nv1-<f()>\n>>");
writeFile(tmpdir, "g1.stg", "f() ::= \"g1\"");
writeFile(tmpdir, "g2.stg", "f() ::= \"g2\"\nf2() ::= \"f2\"\n");
TemplateGroup group = new TemplateGroupFile(tmpdir + "/t.stg");
Template st = group.GetInstanceOf("main");
Assert.AreEqual("v1-g1", st.Render());
// Change the imports of group t.
writeFile(tmpdir, "t.stg",
"import \"g2.stg\"\n\nmain() ::= <<\nv2-<f()>;<f2()>\n>>");
group.Unload(); // will also unload already imported groups
st = group.GetInstanceOf("main");
Assert.AreEqual("v2-g2;f2", st.Render());
}
示例3: TestUnloadingGroupFile
public void TestUnloadingGroupFile()
{
string dir = tmpdir;
string a =
"a(x) ::= <<foo>>\n" +
"b() ::= <<bar>>\n";
writeFile(dir, "a.stg", a);
TemplateGroup group = new TemplateGroupFile(dir + "/a.stg");
group.Load(); // force load
Template st = group.GetInstanceOf("a");
int originalHashCode = RuntimeHelpers.GetHashCode(st);
group.Unload(); // blast cache
st = group.GetInstanceOf("a");
int newHashCode = RuntimeHelpers.GetHashCode(st);
Assert.AreEqual(originalHashCode == newHashCode, false); // diff objects
string expected = "foo";
string result = st.Render();
Assert.AreEqual(expected, result);
st = group.GetInstanceOf("b");
expected = "bar";
result = st.Render();
Assert.AreEqual(expected, result);
}