private static async Task Run(IReadOnlyList <string> args) { string configFilePath = GetConfigFilePath(args); if (configFilePath == null) { throw new ApplicationException("Configuration file not specified."); } Config config = ReadConfig(configFilePath); string constantsOutputPath = !string.IsNullOrWhiteSpace(config.Output.Constants) ? config.Output.Constants : Path.Combine(Directory.GetCurrentDirectory(), "DbMetadata.cs"); string entitiesOutputPath = !string.IsNullOrWhiteSpace(config.Output.Entities) ? config.Output.Entities : Path.Combine(Directory.GetCurrentDirectory(), "DbEntities.cs"); Console.WriteLine($"Connection string: {config.Connection.ConnectionString}"); Console.WriteLine($"Connection type : {config.Connection.Type}"); Console.WriteLine($"Constants output : {constantsOutputPath}"); Console.WriteLine($"Entities output : {entitiesOutputPath}"); using (DbConnection connection = await CreateConnection(config)) { var constantsBuilder = new ConstantsCodeBulder(connection, config); string constantsCode = constantsBuilder.Generate(); File.WriteAllText(constantsOutputPath, constantsCode); Console.WriteLine(constantsCode); var entitiesBuilder = new EntityCodeBuilder(connection, config); string entitiesCode = entitiesBuilder.Generate(); File.WriteAllText(entitiesOutputPath, entitiesCode); Console.WriteLine(entitiesCode); } }
private static async Task Run(IReadOnlyList<string> args) { string configFilePath = GetConfigFilePath(args); if (configFilePath == null) throw new ApplicationException("Configuration file not specified."); Config config = ReadConfig(configFilePath); string constantsOutputPath = !string.IsNullOrWhiteSpace(config.Output.Constants) ? config.Output.Constants : Path.Combine(Directory.GetCurrentDirectory(), "DbMetadata.cs"); string entitiesOutputPath = !string.IsNullOrWhiteSpace(config.Output.Entities) ? config.Output.Entities : Path.Combine(Directory.GetCurrentDirectory(), "DbEntities.cs"); Console.WriteLine($"Connection string: {config.Connection.ConnectionString}"); Console.WriteLine($"Connection type : {config.Connection.Type}"); Console.WriteLine($"Constants output : {constantsOutputPath}"); Console.WriteLine($"Entities output : {entitiesOutputPath}"); using (DbConnection connection = await CreateConnection(config)) { var constantsBuilder = new ConstantsCodeBulder(connection, config); string constantsCode = constantsBuilder.Generate(); File.WriteAllText(constantsOutputPath, constantsCode); Console.WriteLine(constantsCode); var entitiesBuilder = new EntityCodeBuilder(connection, config); string entitiesCode = entitiesBuilder.Generate(); File.WriteAllText(entitiesOutputPath, entitiesCode); Console.WriteLine(entitiesCode); } }