Exemple #1
0
        private static void run(string[] args)
        {
            var config = new CommandArgsConfiguration(args);

              ConsoleUtils.WriteMarkupContent( typeof(Program).GetText("Welcome.txt") );

              if (config.Root["?", "h", "help"].Exists)
              {
             ConsoleUtils.WriteMarkupContent( typeof(Program).GetText("Help.txt") );
             return;
              }

              if (!config.Root.AttrByIndex(0).Exists)
            throw new Exception("Schema file missing");

              var schemaFileName = config.Root.AttrByIndex(0).Value;
              if (string.IsNullOrWhiteSpace(schemaFileName))
            throw new Exception("Schema empty path");

              schemaFileName = Path.GetFullPath(schemaFileName);

              ConsoleUtils.Info("Trying to load schema: " + schemaFileName);

              var schema = new Schema(schemaFileName, new string[] { Path.GetDirectoryName(schemaFileName) });

              ConsoleUtils.Info("Schema file loaded OK");

              var tcompiler = typeof(MySQLCompiler);
              var tcname = config.Root["c", "compiler"].AttrByIndex(0).Value;

              if (!string.IsNullOrWhiteSpace(tcname))
            tcompiler = Type.GetType(tcname, true);

              var compiler = Activator.CreateInstance(tcompiler, new object[] { schema }) as Compiler;

              if (compiler==null) throw new Exception("Could not create compiler type");

              compiler.OutputPath = Path.GetDirectoryName(schemaFileName);

              var options = config.Root["o","opt","options"];
              if (options.Exists)
            compiler.Configure(options);

              ConsoleUtils.Info("Compiler information:");
              Console.WriteLine("   Type={0}\n   Name={1}\n   Target={2}".Args(compiler.GetType().FullName, compiler.Name, compiler.Target) );
              Console.WriteLine("   OutPath={0}".Args(compiler.OutputPath) );
              Console.WriteLine("   OutPrefix={0}".Args(compiler.OutputPrefix) );
              Console.WriteLine("   CaseSensitive={0}".Args(compiler.CaseSensitiveNames) );

              compiler.Compile();

              foreach(var error in compiler.CompileErrors)
            ConsoleUtils.Error(error.ToMessageWithType());

              if (compiler.CompileException!=null)
              {
            ConsoleUtils.Warning("Compile exception thrown");
            throw compiler.CompileException;
              }
        }
Exemple #2
0
 public MsSQLServerCompiler(Schema schema)
     : base(schema)
 {
 }
Exemple #3
0
 public RDBMSCompiler(Schema schema)
     : base(schema)
 {
 }
Exemple #4
0
            public MySQLCompiler(Schema schema) : base(schema)
            {

            }
Exemple #5
0
 public MsSQLServerCompiler(Schema schema) : base(schema)
 {
 }