コード例 #1
0
 public Template(string templateCode, TemplateGroup templateGroup, Type tokenizerType)
 {
     _templateCode = templateCode;
     _tokenizer = (Tokenizer)tokenizerType.GetConstructor(new Type[] { typeof(string) }).Invoke(new object[] { templateCode });
     _parameters = new Dictionary<string, object>();
     _templateGroup = templateGroup;
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: marquismark/stringtemplate
        static void Main(string[] args)
        {
            string groupContent = ReadEmbeddedResource("StringTemplateTester.resources.main.stg");
            TestGroup = new TemplateGroup(groupContent);

            List<ITest> cases = new List<ITest>();
            int cntPass = 0;
            int cntFail = 0;
            Console.WriteLine("Loading All test cases...");
            foreach (Type t in LocateTypeInstances(typeof(ITest),typeof(Program).Assembly))
                cases.Add((ITest)t.GetConstructor(Type.EmptyTypes).Invoke(new object[0]));
            Console.WriteLine("Loading test cases complete...Executing now");
            foreach (ITest test in cases)
            {
                Console.WriteLine("Executing test case " + test.Name + "...");
                if (test.InvokeTest())
                {
                    Console.WriteLine("Test case " + test.Name + " passed successfully");
                    cntPass++;
                }
                else
                {
                    Console.WriteLine("Test case " + test.Name + " failed");
                    cntFail++;
                }
            }
            Console.WriteLine("Test case results:");
            Console.WriteLine("Passes: " + cntPass.ToString());
            Console.WriteLine("Fails: " + cntFail.ToString());
            Console.WriteLine("Total cases: " + cases.Count.ToString());
            Console.WriteLine("Hit enter to exit...");
            Console.ReadLine();
        }
コード例 #3
0
 public Template(TemplateGroup templateGroup, string templateCode) : this(templateCode, templateGroup) { }
コード例 #4
0
 public Template(string templateCode, TemplateGroup templateGroup) : this(templateCode,templateGroup,typeof(DefaultTokenizer))
 { }
コード例 #5
0
 public Template(StreamReader reader,TemplateGroup templateGroup,Type tokenizerType)
     : this(reader.ReadToEnd(),templateGroup,tokenizerType)
 {
     reader.Close();
 }
コード例 #6
0
 public Template(StreamReader reader,TemplateGroup templateGroup)
     : this(reader, templateGroup, typeof(DefaultTokenizer))
 {
 }