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


C# TemplateGroupFile.Unload方法代码示例

本文整理汇总了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());
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:16,代码来源:TestGroups.cs

示例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());
        }
开发者ID:jamilgeor,项目名称:antlrcs,代码行数:17,代码来源:TestImports.cs

示例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);
 }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:23,代码来源:TestGroups.cs


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