private static IEnumerable <IGeneratedFile> GenerateFiles(string configPath) { var options = SimpletOptions.ReadFrom(configPath); var dirInfo = Directory.CreateDirectory(options.TargetDirectory); var csGenerator = new CsGenerator(); var csFiles = csGenerator.Generate(options).ToArray(); var txtGenerator = new TxtGenerator(csFiles.OfType <IGeneratedClass>()); var txtFiles = txtGenerator.Generate(options); var csprojGenerator = new CsProjGenerator(); var csprojFiles = csprojGenerator.Generate(options); foreach (var file in csprojFiles.Concat(txtFiles.Concat(csFiles))) { yield return(new FullPathFile(dirInfo, file)); } }
static void Main(string[] args) { PostgresDbCreator postgresDbCreator = new PostgresDbCreator(); PostgresDbSeeder postgresDbSeeder = new PostgresDbSeeder(); SQLiteDbCreator sqLiteDbCreator = new SQLiteDbCreator(); SQLiteDbSeeder sqLiteDbSeeder = new SQLiteDbSeeder(); PostgresDbExtractor postgresDbExtractor = new PostgresDbExtractor(); SQLiteDbExtractor sqLiteDbExtractor = new SQLiteDbExtractor(); CsvGenerator csvGenerator = new CsvGenerator(); HtmlGenerator htmlGenerator = new HtmlGenerator(); XmlGenerator xmlGenerator = new XmlGenerator(); CsGenerator csGenerator = new CsGenerator(); try { using (DbConnection connection = new SQLiteConnection(Configuration.SQLiteConnectionString)) { connection.Open(); var path = "D:\\sqLite_output"; if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); var sqLiteTables = sqLiteDbExtractor.GetTables(connection); foreach (var sqLiteTable in sqLiteTables.Where(x => x != "sqlite_sequence")) { csvGenerator.Generate(sqLiteDbExtractor, connection, sqLiteTable, path); htmlGenerator.Generate(sqLiteDbExtractor, connection, sqLiteTable, path); xmlGenerator.Generate(sqLiteDbExtractor, connection, sqLiteTable, path); csGenerator.Generate(sqLiteDbExtractor, connection, sqLiteTable, path); } } using (DbConnection connection = new NpgsqlConnection(Configuration.NpgsqlConnectionString)) { connection.Open(); var path = "D:\\pgsql_output"; if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); var pgsqlTables = postgresDbExtractor.GetTables(connection); foreach (var pgsqlTable in pgsqlTables) { csvGenerator.Generate(postgresDbExtractor, connection, pgsqlTable, path); htmlGenerator.Generate(postgresDbExtractor, connection, pgsqlTable, path); xmlGenerator.Generate(postgresDbExtractor, connection, pgsqlTable, path); csGenerator.Generate(postgresDbExtractor, connection, pgsqlTable, path); } } } catch (Exception e) { Console.WriteLine(e.Message); throw; } }