Ejemplo n.º 1
0
 public T4ModelGenTool()
 {
     Generator = new ModelGen
     {
         GenerateLinq       = true,
         GenerateProperties = true,
     };
 }
Ejemplo n.º 2
0
        static int Main(string[] args)
        {
            try
            {
                var x  = T4ModelGenTool.ExtractDataFromTextTemplate(@"C:\Projects\c2j\src\cs2java\Java\Ast\JModel2.tt");
                var xx = new T4ModelGenTool().Debug(@"C:\Projects\c2j\src\cs2java\Java\Ast\JModel2.tt", "JSharp.Java.Ast");
                return(0);

                Console.WriteLine("modelgen " + args.NotNull().StringConcat(" "));
                var tool = ToolArgsParser.Parse <ModelGenTool>(args);
                if (tool.Help)
                {
                    Console.WriteLine(ToolArgsGenerator.GenerateHelp(tool));
                    return(0);
                }
                var gen = new ModelGen
                {
                    SourceFilename     = tool.SourceFilename,
                    GenerateEnum       = tool.GenerateEnum.GetValueOrDefault(true),
                    GenerateLinq       = tool.GenerateLinq.GetValueOrDefault(true),
                    GenerateProperties = tool.GenerateProperties.GetValueOrDefault(true),
                    RootNodeTypeName   = tool.RootNodeTypeName,
                    Namespace          = tool.Namespace,
                };
                if (tool.Using != null)
                {
                    gen.Usings.AddRange(tool.Using);
                }
                gen.Run();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(-1);
            }
            return(0);
            //new JModelGenerator
            //{
            //    SourceFilename = @"..\..\CsModel.txt",
            //    BaseNodeTypeName = "Element",
            //    GenerateLinq = true,
            //    Namespace = "JSharp.CSharp",
            //}.Run();
            //return;
            //new JModelGenerator
            //{
            //    SourceFilename = @"..\..\JModel.txt",
            //    GenerateEnum = true,
            //    GenerateLinq = true,
            //    GenerateProperties = true,
            //    BaseNodeTypeName = "JNode",
            //    Namespace = "JSharp.Java.Ast"
            //}.Run();
        }
Ejemplo n.º 3
0
 public void Run()
 {
     Generator = new ModelGen
     {
         SourceText         = SourceText,
         SourceFilename     = SourceFilename,
         GenerateEnum       = GenerateEnum.GetValueOrDefault(true),
         GenerateLinq       = GenerateLinq.GetValueOrDefault(true),
         GenerateProperties = GenerateProperties.GetValueOrDefault(true),
         RootNodeTypeName   = RootNodeTypeName,
         Namespace          = Namespace,
     };
     if (OutputFilename == null)
     {
         Generator.OutputFilename = SourceFilename.ToFsPath().ChangeExtension(".generated.cs");
     }
     if (Using != null)
     {
         Generator.Usings.AddRange(Using);
     }
     Generator.Run();
 }