/docs/en/Development-Guide-Rad-Tool.md

https://github.com/aspnetzero/documents · Markdown · 130 lines · 86 code · 44 blank · 0 comment · 0 complexity · e84743e68586cb1d679ae58d4c07d34c MD5 · raw file

  1. # Development Guide
  2. In this document, we will introduce **ASP.NET Zero Power Tools** and explain it. ASP.NET Zero Power Tools minimizes the effort for creating CRUD pages. It generates all the layers from the database to the user interface by just defining an entity.
  3. > ASP.NET Zero Power Tools supports ASP.NET Zero v5.0.0 and above versions.
  4. ## How To Use It?
  5. You can use ASP.NET Zero Power Tools in two ways:
  6. 1. as a Visual Studio Extension
  7. 2. Using its DLL files directly with a command line.
  8. Visual Studio Extension is available for Windows version of Visual Studio. Mac and Linux users can use DLL of ASP.NET Zero Power Tools to generate CRUD pages.
  9. ## How It Works?
  10. DLLs (that are inside the ```aspnet-core\AspNetZeroRadTool``` folder in your solution) do all the work. The extension is just a user interface. Since the tool is built with .NET Core, **Mac** or **Linux** users can safely use it without the user interface.
  11. Using ASP.NET Zero Power Tools on Mac and Linux requires a bit more effort. You have to create a [ JSON file](https://aspnetzero.com/Documents/Development-Guide-Rad-Tool-Mac-Linux) as input for code generation manually. For using ASP.NET Zero Power Power Tools in Mac or Linux, please check [Development Guide(Mac/Linux) document](Development-Guide-Rad-Tool-Mac-Linux).
  12. Visual Studio extension of ASP.NET Zero Power Tools also uses this DLL file for code generation.
  13. ## Edit Pre-defined Templates
  14. Power Tools uses text templates for code generation, and these templates are located inside ```/AspNetZeroRadTool/FileTemplates``` directory in your project's root directory. Each template is split into three files:
  15. * **MainTemplate.txt**: Power Tools uses this template for main code generation.
  16. * **PartialTemplates.txt**: Power Tools renders some placeholders in MainTemplate.txt conditionally. These conditional templates are stored in PartialTemplates.txt.
  17. * **TemplateInfo.txt**: Stores information about the template like path and condition.
  18. If you want to edit any file, copy it in the same directory and change it's an extension to ```.custom.txt``` from ```.txt```. For example, you can create ```MainTemplate.custom.txt``` to override ```MainTemplate.txt``` in the same directory. Please don't make any changes to the original templates.
  19. ## Create A New Template
  20. You can also create new templates for code generation. Power Tools will generate new files based on your new templates during code generation. To create a new template, do the same process as editing a pre-defined template.
  21. Power Tools discovers templates in the ```/FileTemplates``` directory every time it is run. So, restarting Power Tools will find your newly created templates.
  22. ## Change Destination Path Of New Files
  23. To change the destination path of a template, find the template folder of it in "AspNetZeroRadTool/FileTemplates" directory and edit the content of **TemplateInfo.txt** file.
  24. Also, if you have moved a file that is going to be modified during rad tool generation, you can modify "AspNetZeroRadTool/**config.json**" file and set the new path of this file.
  25. ## Generated Files
  26. Here is the full list of the files that are created or modified by the tool, if you give a basic "Cars" entity as input.
  27. ### Server Side
  28. **Files that are being created**
  29. - Car.cs
  30. - CarDto.cs
  31. - LookupDto.cs
  32. - GetAllForLookupTableInput.cs
  33. - GetCarForEditOutput.cs
  34. - GetAllCarsOutput.cs
  35. - CreateOrEditCarDto.cs
  36. - GetAllCarsInput.cs
  37. - CarConsts.cs
  38. - ICarAppService
  39. - CarAppService
  40. - CarsExcelExporter.cs
  41. - ICarsExcelExporter.cs
  42. **Files that are being modified**
  43. - AppAuthorizationProvider.cs
  44. - AppPermissions.cs
  45. - ProjectNameDbContext.cs
  46. - CustomDtoMapper.cs
  47. - ProjectName.xml (English localization file)
  48. (Optionally, adds a database migration and updates the database.)
  49. ### Client Side
  50. #### Angular
  51. **Files that are being created**
  52. - cars.component.ts
  53. - cars.component.html
  54. - create-or-edit-car-modal.component.ts or create-or-edit-car.component.ts (if "Create Non-modal CRUD Page" is selected)
  55. - create-or-edit-car-modal.component.html or create-or-edit-car.component.html (if "Create Non-modal CRUD Page" is selected)
  56. - view-car-modal.component.ts or view-car.component.ts (if "Create Non-modal CRUD Page" is selected)
  57. - view-car-modal.component.html or view-car.component.ts (if "Create Non-modal CRUD Page" is selected)
  58. - Lookup-Table-modal.component.ts
  59. - Lookup-Table-modal.component.html
  60. - Lookup-Table-modal.component.less
  61. **Files that are being modified**
  62. - app-navigation.service.ts
  63. - service-proxy.module.ts
  64. - (Main or Admin)-routing.module.ts
  65. - (Main or Admin).module.ts
  66. #### Mvc
  67. **Files that are being created**
  68. - CarsController.cs
  69. - CarsViewModel.cs
  70. - CreateOrEditCarViewModel.cs
  71. - Index.js
  72. - Index.cshtml
  73. - CreateOrEditModal.js or CreateOrEdit.js (if "Create Non-modal CRUD Page" is selected)
  74. - CreateOrEditModal.cshtml or CreateOrEdit.cshtml (if "Create Non-modal CRUD Page" is selected)
  75. - ViewCarModal.cshtml or ViewCar.cshtml (if "Create Non-modal CRUD Page" is selected)
  76. - LookupTableViewModel.cshtml
  77. - LookupTableModal.js
  78. - LookupTableModal.cshtml
  79. **Files that are being modified**
  80. - (AppArea)NavigationProvider.cs
  81. - (AppArea)PageNames.cs
  82. > Note that lookup files are being created per foreign key.
  83. ## Final Result
  84. The below image shows a generated page which list records, allows filtering, inserting, deleting, updating and exporting excel functionalities.![Final result: generated page](images/RadToolCarsTable3.jpg)
  85. This is the record edit model where you can update an existing record.
  86. ![Edit model](images/RadToolEditModal.jpg)