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


C# StringTemplateGroup.GetInstanceOf方法代码示例

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


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

示例1: createContent

        private void createContent(String varName, Object objectToPass, StringReader reader, String outputFileName)
        {
            Dictionary<String, Object> map = new Dictionary<String, Object>();
            map.Add(varName, objectToPass);

            String outputContent = null;
            StringTemplateGroup group = new StringTemplateGroup(reader);
            var contentTemplate = group.GetInstanceOf("Content");
            contentTemplate.Attributes = map;
            outputContent = contentTemplate.ToString();
            //StringBuilder sb = new StringBuilder(outputContent);
            StringWriter writer = new StringWriter(new StringBuilder(outputContent));
            writer.Flush();
            StreamWriter fileWriter = null;
            try
            {
                fileWriter = new StreamWriter(outputFileName + "/report.html.data");
                fileWriter.Write(writer.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            writer.Close();
            fileWriter.Close();
        }
开发者ID:VTAF,项目名称:VirtusaCodedUIRuntime,代码行数:27,代码来源:Generator.cs

示例2: EvaluateFile

 public string EvaluateFile(string fileName, IDictionary<string, object> context)
 {
     var stringTemplateGroup = new StringTemplateGroup("group", AppDomain.CurrentDomain.BaseDirectory);
     stringTemplateGroup.ErrorListener = new StringTemplateErrorListener();
     StringTemplate stringTemplate = stringTemplateGroup.GetInstanceOf(fileName, context);
     return stringTemplate.ToString();
 }
开发者ID:smartinz,项目名称:randomhacking,代码行数:7,代码来源:Class1.cs

示例3: GenerateSummary

        //This function is used to generate the summary of whole target projet. The summary is showed in the left part of our report, the details is defined in the two HashSet above.
        public void GenerateSummary(string stsum)
        {
            Console.WriteLine("Now let's generate summary..");
            foreach(var table in db.tablesInfo)
            {
                table.generateDescription(db);
                if (table.directMethods.Count>0 || table.columns.Find(x => x.directMethods.Count>0)!=null)
                {
                    SingleSummary tcSummary = new SingleSummary(table.title, table.attribute, table.methodsDes,table.name,table.generateLeftIndex());
                    AllTableSummary.Add(tcSummary);
                }
                foreach(var column in table.columns)
                {
                    column.generateDescription(db);
                    if (column.directMethods.Count == 0) continue;
                    SingleSummary tcSummary = new SingleSummary(column.title, column.attribute, column.methodsDes,table.name,"");
                    AllColumnSummary.Add(tcSummary);
                }
            }

            //generating Javascript for webpage
            StringTemplateGroup group = new StringTemplateGroup("myGroup", @".\Templet");
            StringTemplate st = group.GetInstanceOf("GenerateScript");
            foreach(var me in extractor.methodsInfo)
            {
                st.SetAttribute("FunctionName",TakePointOff(me.name));
                st.SetAttribute("MethodFullName",me.name);
                st.SetAttribute("MethodName", me.methodself.Name);
            }
            FinalGenerator homePageGenerator = new FinalGenerator(this.AllTableSummary, this.AllColumnSummary,st.ToString(),stsum);
            homePageGenerator.Generate(outputLoc);
        }
开发者ID:boyangwm,项目名称:DBScribe-Ext,代码行数:33,代码来源:infoCollector.cs

示例4: Generate

        public void Generate(string path)
        {
            StringTemplateGroup group = new StringTemplateGroup("myGroup", @".\Templet");
            StringTemplate st = group.GetInstanceOf("CourseHome");
            int ID = 1;
            st.SetAttribute("Function", AllShiftFunction);
            st.SetAttribute("ProjectSum", projectSum);
            foreach (var testSummary in AllTableSummary) {
                st.SetAttribute("IDNum", ID++);
                st.SetAttribute("Title", testSummary.title);
                st.SetAttribute("Content", testSummary.attributions + "</p>" + testSummary.methodInfo);
                st.SetAttribute("Index", testSummary.tableIndex);
                foreach (var subSummary in AllColumnSummary)
                {
                    if (subSummary.tableName != testSummary.tableName) continue;
                    st.SetAttribute("IDNum", ID++);
                    st.SetAttribute("Title", subSummary.title);
                    st.SetAttribute("Content", subSummary.attributions + "</p>" + subSummary.methodInfo);
                }

            }

            String result = st.ToString();
            StreamWriter writetext = new StreamWriter(path);
            writetext.WriteLine(result);
            writetext.Close();
        }
开发者ID:boyangwm,项目名称:DBScribe-Ext,代码行数:27,代码来源:FinalGenerator.cs

示例5: RenderTemplate

        public string RenderTemplate(string groupName, string groupPath, string templateName, IEnumerable<KeyValuePair<string, object>> templateData)
        {
            var templateGroup = new StringTemplateGroup(groupName, groupPath);
            var template = templateGroup.GetInstanceOf(templateName);

            foreach(var d in templateData)
            {
                template.SetAttribute(d.Key, d.Value);
            }

            template.RegisterRenderer(typeof(DateTime), new DateRenderer());
            template.RegisterRenderer(typeof(String), new BasicFormatRenderer());

            return template.ToString();
        }
开发者ID:irobinson,项目名称:BeerCollectionMVP,代码行数:15,代码来源:Template.cs

示例6: run

        //This method would generate the summary for the project and prepare all the other data for final report.
        public void run()
        {
            Console.WriteLine("Starting collecting data for reporter");

            StringTemplateGroup group = new StringTemplateGroup("myGroup", @".\Templet");
            StringTemplate stsum = group.GetInstanceOf("ProjectSummary");
            int tableCount = 0;
            int totalCount = 0;
            foreach (var tempT in db.tablesInfo)
            {
                if (tempT.directMethods.Count > 0) { tableCount++; totalCount++; }
                foreach (var tempC in tempT.columns)
                {
                    if (tempC.directMethods.Count > 0) totalCount++;
                }
            }
            stsum.SetAttribute("TableNumber", tableCount);
            stsum.SetAttribute("AllNumber", totalCount);
            stsum.SetAttribute("MethodNumber", extractor.allDirectMethods.Count);
            GenerateSummary(stsum.ToString());
        }
开发者ID:boyangwm,项目名称:DBScribe-Ext,代码行数:22,代码来源:infoCollector.cs

示例7: getHtmlDescribe

 //This method would generate the description of this method and we could show the description in the final report.
 public string getHtmlDescribe(List<string> allSql, string TorC, string optType)
 {
     string htmlText = "";
     StringTemplateGroup group = new StringTemplateGroup("myGroup", @".\Templet");
     StringTemplate st = group.GetInstanceOf("MethodDes");
     st.SetAttribute("FunctionName", TakePointOff(name));
     st.SetAttribute("MethodFullName", name);
     st.SetAttribute("MethodName", methodself.Name);
     st.SetAttribute("MethodSum", swumsummary);
     if (allSql != null)
     {
         foreach (var singleSql in allSql)
         {
             var tempText = translateStmt(singleSql, TorC, optType);
             if (tempText == "") continue;
             st.SetAttribute("SQLs", translateStmt(singleSql, TorC, optType));
         }
     }
     htmlText = st.ToString();
     return htmlText;
 }
开发者ID:boyangwm,项目名称:DBScribe-Ext,代码行数:22,代码来源:desMethod.cs

示例8: TestGroupTrailingSemiColon

        public void TestGroupTrailingSemiColon()
        {
            //try {
                string templates =
                        "group test;" + newline +
                        "t1()::=\"R1\"; " + newline +
                        "t2() ::= \"R2\"" + newline
                        ;
                StringTemplateGroup group =
                        new StringTemplateGroup( new StringReader( templates ) );

                StringTemplate st = group.GetInstanceOf( "t1" );
                Assert.AreEqual( "R1", st.ToString() );

                st = group.GetInstanceOf( "t2" );
                Assert.AreEqual( "R2", st.ToString() );

                Assert.Fail( "A parse error should have been generated" );
            //} catch (ParseError??) {
            //}
        }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:21,代码来源:StringTemplateTests.cs

示例9: TestComplicatedIndirectTemplateApplication

 public void TestComplicatedIndirectTemplateApplication()
 {
     string templates =
             "group Java;" + newline +
             "" + newline +
             "file(variables) ::= <<" +
             "<variables:{ v | <v.decl:(v.format)()>}; separator=\"\\n\">" + newline +
             ">>" + newline +
             "intdecl(decl) ::= \"int <decl.name> = 0;\"" + newline +
             "intarray(decl) ::= \"int[] <decl.name> = null;\"" + newline
             ;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ) );
     StringTemplate f = group.GetInstanceOf( "file" );
     f.SetAttribute( "variables.{decl,format}", new Decl( "i", "int" ), "intdecl" );
     f.SetAttribute( "variables.{decl,format}", new Decl( "a", "int-array" ), "intarray" );
     //System.out.println("f='"+f+"'");
     string expecting = "int i = 0;" + newline +
             "int[] a = null;";
     Assert.AreEqual( expecting, f.ToString() );
 }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:21,代码来源:StringTemplateTests.cs

示例10: TestArgumentsAsTemplatesDefaultDelimiters

 public void TestArgumentsAsTemplatesDefaultDelimiters()
 {
     string templates =
             "group test;" + newline +
             "method(name,size) ::= <<" + newline +
             "$stat(value={$size$})$" + newline +
             ">>" + newline +
             "stat(value) ::= \"x=$value$;\"" + newline
             ;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ),
                                     typeof( DefaultTemplateLexer ) );
     StringTemplate b = group.GetInstanceOf( "method" );
     b.SetAttribute( "name", "foo" );
     b.SetAttribute( "size", "34" );
     string expecting = "x=34;";
     string result = b.ToString();
     Assert.AreEqual( expecting, result );
 }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:19,代码来源:StringTemplateTests.cs

示例11: TestRepeatedRestOpAsArg

 public void TestRepeatedRestOpAsArg()
 {
     String templates =
             "group test;" + newline +
             "root(names) ::= \"$other(rest(names))$\"" + newline +
             "other(x) ::= \"$x$, $x$\"" + newline
             ;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ),
                                     typeof( DefaultTemplateLexer ) );
     StringTemplate e = group.GetInstanceOf( "root" );
     e.SetAttribute( "names", "Ter" );
     e.SetAttribute( "names", "Tom" );
     String expecting = "Tom, Tom";
     Assert.AreEqual( expecting, e.ToString() );
 }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:16,代码来源:StringTemplateTests.cs

示例12: TestWhiteSpaceAtEndOfTemplate

 public void TestWhiteSpaceAtEndOfTemplate()
 {
     StringTemplateGroup group = new StringTemplateGroup( "group", System.Reflection.Assembly.GetExecutingAssembly() );
     StringTemplate pageST = group.GetInstanceOf( "AntlrUnitTests/page" );
     StringTemplate listST = group.GetInstanceOf( "AntlrUnitTests/users_list" );
     // users.list references row.st which has a single blank line at the end.
     // I.e., there are 2 \n in a row at the end
     // ST should eat all whitespace at end
     listST.SetAttribute( "users", new Connector() );
     listST.SetAttribute( "users", new Connector2() );
     pageST.SetAttribute( "title", "some title" );
     pageST.SetAttribute( "body", listST );
     string expecting = "some title" + newline +
         "Terence [email protected] [email protected]";
     string result = pageST.ToString();
     //System.out.println("'"+result+"'");
     Assert.AreEqual( expecting, result );
 }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:18,代码来源:StringTemplateTests.cs

示例13: TestArgumentsAsTemplates

 public void TestArgumentsAsTemplates()
 {
     string templates =
             "group test;" + newline +
             "method(name,size) ::= <<" + newline +
             "<stat(value={<size>})>" + newline +
             ">>" + newline +
             "stat(value) ::= \"x=<value>;\"" + newline
             ;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ) );
     StringTemplate b = group.GetInstanceOf( "method" );
     b.SetAttribute( "name", "foo" );
     b.SetAttribute( "size", "34" );
     string expecting = "x=34;";
     string result = b.ToString();
     Assert.AreEqual( expecting, result );
 }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:18,代码来源:StringTemplateTests.cs

示例14: GetTemplate

 public string GetTemplate(string groupName, string groupPath, string templateName)
 {
     var templateGroup = new StringTemplateGroup(groupName, groupPath);
     return templateGroup.GetInstanceOf(templateName).Template;
 }
开发者ID:irobinson,项目名称:BeerCollectionMVP,代码行数:5,代码来源:Template.cs

示例15: TestTemplateArgumentEvaluatedInSurroundingContext

 public void TestTemplateArgumentEvaluatedInSurroundingContext()
 {
     string templates =
             "group test;" + newline +
             "file(m,size) ::= \"<m>\"" + newline +
             "method(name) ::= <<" + newline +
             "<stat(value={<size>.0})>" + newline +
             ">>" + newline +
             "stat(value) ::= \"x=<value>;\"" + newline
             ;
     StringTemplateGroup group =
             new StringTemplateGroup( new StringReader( templates ) );
     StringTemplate f = group.GetInstanceOf( "file" );
     f.SetAttribute( "size", "34" );
     StringTemplate m = group.GetInstanceOf( "method" );
     m.SetAttribute( "name", "foo" );
     f.SetAttribute( "m", m );
     string expecting = "x=34.0;";
     string result = m.ToString();
     Assert.AreEqual( expecting, result );
 }
开发者ID:JSchofield,项目名称:antlrcs,代码行数:21,代码来源:StringTemplateTests.cs


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