internal void GenerateClass(string currentPath) { ModelHost host1 = new ModelHost(); Parsercsproj parseproj = new Parsercsproj(currentPath); host1.ClassName = className; host1.ClassFields = fields; host1.IdField= fields.FirstOrDefault(x => x.Name.Equals("id", StringComparison.InvariantCultureIgnoreCase)); host1.NameSpace = parseproj.RootNameSpace + ".Models"; string output = host1.ProcessTemplate(); string filePath=Path.Combine(currentPath, "Models", className + ".cs"); File.WriteAllText(filePath, output,Encoding.UTF8); parseproj.AddCompileFile("Models\\" + className + ".cs"); parseproj.Save(); }
private static void VerifyAndCheckAssets(string currentPath, string assetFolder, string[] files) { string AssetsPath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Templates", "Assets", assetFolder); Parsercsproj parserProj = new Parsercsproj(currentPath); foreach (string asset in files) { if (!File.Exists(Path.Combine(currentPath, "Assets", assetFolder, asset))) { File.Copy(Path.Combine(AssetsPath, asset), Path.Combine(currentPath, "Assets", assetFolder, asset)); parserProj.AddContentFile("Assets\\" + assetFolder + "\\" + asset, CopyOutPutOptions.PreserveNewest); } } parserProj.Save(); }
private void GenerateMigrationClass(string currentPath) { MigrationHost host = new MigrationHost(); Parsercsproj parseproj = new Parsercsproj(currentPath); host.ClassName = className; host.ClassFields = fields; host.MigrationSet=DateTime.Now.ToString("yyyyMMddHHmmss"); host.IdField = fields.FirstOrDefault(x => x.Name.Equals("id", StringComparison.InvariantCultureIgnoreCase)); host.NameSpace = parseproj.RootNameSpace + ".Migrations"; string output = host.ProcessTemplate(); string filePath = Path.Combine(currentPath, "Migrations", "create"+className + ".cs"); File.WriteAllText(filePath, output, Encoding.UTF8); parseproj.AddCompileFile("Migrations\\create" + className + ".cs"); parseproj.Save(); }