private static void ScaffoldReadMe(this EntityFrameworkCoreProject project) { var lines = new List <string> { "CatFactory: Scaffolding Made Easy", string.Empty, "How to use this code on your ASP.NET Core Application:", string.Empty, "1. Install packages for EntityFrameworkCore and EntityFrameworkCore.SqlServer", string.Empty, "2. Register your DbContext and repositories in ConfigureServices method (Startup class):", string.Format(" services.AddDbContext<{0}>(options => options.UseSqlServer(Configuration[\"ConnectionString\"]));", project.Database.GetDbContextName()), " services.AddScoped<IDboRepository, DboRepository>();", string.Empty, "Happy scaffolding!", string.Empty, "You can check the guide for this package in:", "https://www.codeproject.com/Articles/1160615/Scaffolding-Entity-Framework-Core-with-CatFactory", string.Empty, "Also you can check source code on GitHub:", "https://github.com/hherzl/CatFactory.EntityFrameworkCore", string.Empty, "*** Soon CatFactory will scaffold code for Entity Framework Core 2.0 (December - 2017) ***", string.Empty, "CatFactory Development Team ==^^==" }; TextFileHelper.CreateFile(Path.Combine(project.OutputDirectory, "ReadMe.txt"), lines.ToStringBuilder().ToString()); }
public void SerializeExistingDatabaseTest() { // Arrange var databaseFactory = new SqlServerDatabaseFactory { ConnectionString = "server=(local);database=AdventureWorks2012;integrated security=yes;MultipleActiveResultSets=true;", ImportSettings = new DatabaseImportSettings { ImportMSDescription = true, Exclusions = new List <string> { "dbo.EventLog" } } }; // Act var database = databaseFactory.Import(); var serializer = new Serializer(); var output = serializer.Serialize(database); TextFileHelper.CreateFile("C:\\Temp\\CatFactory.SqlServer\\AdventureWorks2012.xml", output); // Assert }
private static void ScaffoldReadMe(this DapperProject project) { var lines = new List <string> { "CatFactory: Scaffolding Made Easy", string.Empty, "How to use this code on your ASP.NET Core Application", string.Empty, "Register objects in Startup class, register your repositories in ConfigureServices method:", " services.AddScoped<IDboRepository, DboRepository>();", string.Empty, "Happy coding!", string.Empty, "You can check the guide for this package in:", "https://www.codeproject.com/Articles/1213355/Scaffolding-Dapper-with-CatFactory", string.Empty, "You can check source code on GitHub:", "https://github.com/hherzl/CatFactory.Dapper", string.Empty, "*** Special Thanks for Edson Ferreira to let me help for Dapper community ***", string.Empty, "CatFactory Development Team ==^^==" }; TextFileHelper.CreateFile(Path.Combine(project.OutputDirectory, "CatFactory.Dapper.ReadMe.txt"), lines.ToStringBuilder().ToString()); }
public virtual void CreateFile(string subdirectory = "", string fileName = "") { Logger?.LogDebug("'{0}' has been invoked", nameof(CreateFile)); CreateOutputDirectory(); var filePath = string.IsNullOrEmpty(fileName) ? Path.Combine(OutputDirectory, subdirectory, FilePath) : Path.Combine(OutputDirectory, subdirectory, fileName); if (!ForceOverwrite && File.Exists(filePath)) { throw new CodeFactoryException(string.Format("The '{0}' file alread exists, if you want to overwrite set ForceOverwrite property as true", filePath)); } if (!string.IsNullOrEmpty(subdirectory)) { var subdirectoryPath = Path.Combine(OutputDirectory, subdirectory); if (!Directory.Exists(subdirectoryPath)) { Logger?.LogInformation("Creating '{0}' directory...", subdirectoryPath); Directory.CreateDirectory(subdirectoryPath); } } Logger?.LogInformation("Creating '{0}' file...", filePath); Translating(); OnTranslatedDefinition(new TranslatedDefinitionEventArgs(Logger)); TextFileHelper.CreateFile(filePath, Lines.ToStringBuilder().ToString()); }
public void SerializeMockDatabaseTest() { // Arrange var database = Databases.Store; // Act var output = XmlSerializerHelper.Serialize(database); TextFileHelper.CreateFile("C:\\Temp\\CatFactory.SqlServer\\Store.xml", output); // Assert }
public virtual void CreateFile(string subdirectory = "", string fileName = "") { Logger?.LogDebug("'{0}' has been invoked", nameof(CreateFile)); CreateOutputDirectory(); var filePath = string.IsNullOrEmpty(fileName) ? Path.Combine(OutputDirectory, subdirectory, FilePath) : Path.Combine(OutputDirectory, subdirectory, fileName); if (!ForceOverwrite && File.Exists(filePath)) { throw new CodeFactoryException(string.Format("A file with path '{0}' alread exists, if you want to overwrite, set ForceOverwrite proerty to true", filePath)); } if (!string.IsNullOrEmpty(subdirectory)) { var subdirectoryPath = Path.Combine(OutputDirectory, subdirectory); if (!Directory.Exists(subdirectoryPath)) { Logger?.LogInformation("Creating '{0}' directory...", subdirectoryPath); Directory.CreateDirectory(subdirectoryPath); } } Logger?.LogInformation("Creating '{0}' file...", filePath); if (Lines.Count == 0) { TextFileHelper.CreateFile(filePath, Code); } else { TextFileHelper.CreateFile(filePath, Lines.ToStringBuilder().ToString()); } }