public static void GenerateViewModels(string path, string autogenWarningText) { //Eyðum möppu DeleteViewModels(path); //Búum möppu til upp á nýtt System.IO.Directory.CreateDirectory(path); foreach (var element in DatabaseMockup.Get_className_tableName_categoryName_List()) { //Náum í alla flags sem eru á tölfunni(ClassName) var flags = DatabaseMockup.GetFlagsForClassName(element.Item1); //Generate-um ClassNameViewModel file-ana, ef það er eitthvað view notað(Create, Edit eða Details) þá þurfum við ViewModel fyrir það if (!(flags.Contains("NoCreate") && flags.Contains("NoEdit") && flags.Contains("NoDetails"))) { GenerateViewModelFile(GenerateViewModelText("ViewModel", "ViewModel", element.Item1, element.Item2, element.Item3, autogenWarningText), element.Item1, element.Item3, path); } //Generate-um ClassNameListViewModel file-ana if (!(flags.Contains("NoList"))) { GenerateViewModelFile(GenerateViewModelText("ViewModel", "ViewModelList", element.Item1, element.Item2, element.Item3, autogenWarningText), element.Item1 + "List", element.Item3, path); } } }
public static void GenerateViews(string path, string autogenWarningText) { //Eyðum möppu DeleteViews(path); //Búum möppu til upp á nýtt System.IO.Directory.CreateDirectory(path); foreach (var element in DatabaseMockup.Get_className_tableName_categoryName_List()) { //Generate-um Create view if (!(DatabaseMockup.GetFlagsForClassName(element.Item1).Contains("NoCreate"))) { GenerateViewFile(GenerateViewText("CreateEdit", "CreateView", element.Item1, element.Item2, element.Item3, autogenWarningText), element.Item1, "Create" + element.Item1, element.Item3, path); } //Generate-um Edit view if (!(DatabaseMockup.GetFlagsForClassName(element.Item1).Contains("NoEdit"))) { GenerateViewFile(GenerateViewText("CreateEdit", "EditView", element.Item1, element.Item2, element.Item3, autogenWarningText), element.Item1, "Edit" + element.Item1, element.Item3, path); } //Generate-um Details view if (!(DatabaseMockup.GetFlagsForClassName(element.Item1).Contains("NoDetails"))) { GenerateViewFile(GenerateViewText("Details", "DetailsView", element.Item1, element.Item2, element.Item3, autogenWarningText), element.Item1, "Details" + element.Item1, element.Item3, path); } //Generate-um List view if (!(DatabaseMockup.GetFlagsForClassName(element.Item1).Contains("NoList"))) { GenerateViewFile(GenerateViewText("List", "ListView", element.Item1, element.Item2, element.Item3, autogenWarningText), element.Item1, element.Item2, element.Item3, path); } } }
//Býr til texta fyrir allar functions sem einn klasi þarf innan controllers private static string GenerateControllerTextForSingleClass(string templateType, string templateName, string ClassName, string TableName, string CategoryName) { //Náum í alla flags sem eru á tölfunni(ClassName) var flags = DatabaseMockup.GetFlagsForClassName(ClassName); //Byrjum á að smíða loka template strenginn, string controllerString = ""; //Setjum inn smá comment á milli tafla(klasa) til að það verði skýrara að skoða controller-inn. controllerString += "\t\t/*\r\n"; controllerString += "\t\t\t" + ClassName + " functions\r\n"; controllerString += "\t\t*/\r\n"; //Setjum inn List functions if (!(flags.Contains("NoList"))) { controllerString += GetPropertiesTextForControllerFunctionString(templateType, templateName + "List", ClassName, TableName, CategoryName); } //Setjum inn Create functions if (!(flags.Contains("NoCreate"))) { controllerString += GetPropertiesTextForControllerFunctionString(templateType, templateName + "Create", ClassName, TableName, CategoryName); } //Setjum inn Edit functions if (!(flags.Contains("NoEdit"))) { controllerString += GetPropertiesTextForControllerFunctionString(templateType, templateName + "Edit", ClassName, TableName, CategoryName); } //Setjum inn Details function if (!(flags.Contains("NoDetails"))) { controllerString += GetPropertiesTextForControllerFunctionString(templateType, templateName + "Details", ClassName, TableName, CategoryName); } //Setjum inn Delete function if (!(flags.Contains("NoDelete"))) { controllerString += TemplateParser.ParseTemplate(templateType, templateName + "Delete", ClassName, TableName, CategoryName, "") + Environment.NewLine + Environment.NewLine; } //Ef að engin functions fyrir þessa töflu áttu að fara í controller-inn, þá setjum við inn eitt línubil til að jafna útlitið á generated controller-num if (flags.Contains("NoList") && flags.Contains("NoCreate") && flags.Contains("NoEdit") && flags.Contains("NoDetails") && flags.Contains("NoDelete")) { controllerString += Environment.NewLine; } return(controllerString); }