public void TestStrongTypesRepo() { var folder = @"..\UnitTests\TestAtoms\CareRelated"; var args = new GeneratorArguments <CSharpTargetConfig>( new CSharpTargetConfig { Entities = { StrongTypes = true } }, folder, AtomCreator.LoadDefaults(folder)); var sqlArgs = new GeneratorArguments <SqlTargetConfig>(new SqlTargetConfig(), args.AtomsFolder, AtomCreator.LoadDefaults(folder)); var sqlGenerator = new SqlGenerator().Generate(sqlArgs); var result = new RepositoryGenerator(sqlGenerator).Generate(args); foreach (var item in result) { Console.WriteLine(item.Output); } }
public void TestStrongTypesCode() { var folder = @"..\UnitTests\TestAtoms\CareRelated"; var result = new CodeGenerator().Generate(new GeneratorArguments <CSharpTargetConfig>(new CSharpTargetConfig() { Entities = { StrongTypes = true } }, folder, AtomCreator.LoadDefaults(folder))); foreach (var item in result) { Console.WriteLine(item.Output); } }
public void Test() { var folder = @"..\UnitTests\TestAtoms\CareRelated"; var result = new CodeGenerator().Generate(new GeneratorArguments <CSharpTargetConfig>(new CSharpTargetConfig(), folder, AtomCreator.LoadDefaults(folder))); }
private IEnumerable <GeneratorResult> FromTargetConfigs(CSharpTargetConfig targetConfig) { var args = new GeneratorArguments <CSharpTargetConfig>(targetConfig, AtomsFolder, AtomCreator.LoadDefaults(AtomsFolder)); if (targetConfig.Repository != null) { var sqlArgs = new GeneratorArguments <SqlTargetConfig>(new SqlTargetConfig(), args.AtomsFolder, AtomCreator.LoadDefaults(AtomsFolder)); var sqlGenerator = new SqlGenerator().Generate(sqlArgs); var repoResult = new RepositoryGenerator(sqlGenerator).Generate(args); repoResult.OutputPath = targetConfig.Repository.OutputPath; yield return(repoResult); } var codeResult = new CodeGenerator().Generate(args); codeResult.OutputPath = targetConfig.Entities.OutputPath; yield return(codeResult); }
protected override IEnumerable <GeneratorResult> Generate() { AtomConfig config = TryLoadAtomConfig(); if (config == null) { yield break; } var sqlConfig = config.Targets.Values.OfType <SqlTargetConfig>().Single(); var csharpConfig = config.Targets.Values.OfType <CSharpTargetConfig>().Single(); var defaults = AtomCreator.LoadDefaults(config.AtomPath); var sqlArgs = new GeneratorArguments <SqlTargetConfig>(sqlConfig, config.AtomPath, defaults); var args = new GeneratorArguments <CSharpTargetConfig>(csharpConfig, config.AtomPath, defaults, sqlArgs.Atoms); var sqlResult = new SqlGenerator().Generate(sqlArgs); sqlResult.OutputPath = sqlConfig.OutputPath; //if (Directory.Exists(sqlResult.OutputPath)) //{ // foreach (var file in Directory.EnumerateFiles(sqlResult.OutputPath, "*.generated.sql", SearchOption.AllDirectories)) // { // sqlResult.Deletions.Add(file); // } //} string redGateFile = Path.Combine(sqlConfig.OutputPath, "RedGateDatabaseInfo.xml"); Log.Information("Looking for redgate database info xml at {RedGateDatabaseInfoXml}", redGateFile); if (sqlResult.DataFiles.Any() && File.Exists(redGateFile)) { Log.Information("Found redgate file, updating..."); var regate = XDocument.Load(uri: redGateFile); var dataFiles = regate.Root.Elements("DataFileSet").First(); var allDataFiles = dataFiles.Elements("DataFile") .Select(n => n.Value).Union(sqlResult.DataFiles, StringComparer.OrdinalIgnoreCase).ToList(); dataFiles.Elements("Count") .First() .Value = allDataFiles.Count().ToString(); Log.Information("DataFiles Count: {DataFileCount}", allDataFiles.Count()); dataFiles.Elements("DataFile").Remove(); dataFiles.Add(allDataFiles.Select(s => new XElement("DataFile", s))); var genResult = new GeneratorResult() { OutputPath = sqlConfig.OutputPath }; genResult.AddOutput("RedGateDatabaseInfo.xml", regate.ToString()); yield return(genResult); } yield return(sqlResult); if (csharpConfig.Repository != null) { var repoResult = new RepositoryGenerator(sqlResult).Generate(args); repoResult.OutputPath = csharpConfig.Repository.OutputPath; yield return(repoResult); } var codeResult = new CodeGenerator().Generate(args); codeResult.OutputPath = csharpConfig.Entities.OutputPath; yield return(codeResult); }
private IEnumerable <GeneratorResult> FromTargetConfigs(SqlTargetConfig sqlConfig) { var args = new GeneratorArguments <SqlTargetConfig>(sqlConfig, AtomsFolder, AtomCreator.LoadDefaults(AtomsFolder)); var sqlResult = new SqlGenerator().Generate(args); sqlResult.OutputPath = sqlConfig.OutputPath; if (Directory.Exists(sqlResult.OutputPath)) { foreach (var file in Directory.EnumerateFiles(sqlResult.OutputPath, "*.generated.sql", SearchOption.AllDirectories)) { sqlResult.Deletions.Add(file); } } string redGateFile = Path.Combine(sqlConfig.OutputPath, "RedGateDatabaseInfo.xml"); Log.Information("Looking for redgate database info xml at {RedGateDatabaseInfoXml}", redGateFile); if (sqlResult.DataFiles.Any() && File.Exists(redGateFile)) { Log.Information("Found redgate file, updating..."); var regate = XDocument.Load(uri: redGateFile); var dataFiles = regate.Root.Elements("DataFileSet").First(); var allDataFiles = dataFiles.Elements("DataFile") .Select(n => n.Value).Union(sqlResult.DataFiles, StringComparer.OrdinalIgnoreCase).ToList(); dataFiles.Elements("Count") .First() .Value = allDataFiles.Count().ToString(); Log.Information("DataFiles Count: {DataFileCount}", allDataFiles.Count()); dataFiles.Elements("DataFile").Remove(); dataFiles.Add(allDataFiles.Select(s => new XElement("DataFile", s))); var genResult = new GeneratorResult() { OutputPath = _config.OutputPath }; genResult.AddOutput("RedGateDatabaseInfo.xml", regate.ToString()); yield return(genResult); } yield return(sqlResult); }