1 class ScaffoldGenerator(NamedGeneratorBase
):
2 [Property(Area
)] _area
as string
3 [Property(Controller
)] _controller
as string
4 [Property(Model
)] _model
as string
9 # controller name is specified
10 matches
= /((\w
+)\
/|
)(\w
+)/.Match(Argv
[0])
11 _area
= matches
.Groups
[2].Value
12 _controller
= matches
.Groups
[3].Value
14 # controller name is not specified so
15 # it is plural of model name
16 _controller
= _model
.ToPlural()
18 if Area
== "" or Area
== null:
20 controllerPath
= ControllersBasePath
21 controllerTestPath
= ControllersTestsBasePath
22 viewPath
= "${ViewsBasePath}/${ControllerFileName}"
24 controllerPath
= "${ControllersBasePath}/${Area.ToLower()}"
25 controllerTestPath
= "${ControllersTestsBasePath}/${Area.ToLower()}"
26 viewPath
= "${ViewsBasePath}/${Area.ToLower()}/${ControllerFileName}"
28 MkDir(ControllersBasePath
)
29 Process('ApplicationController.cs', "${ControllersBasePath}/ApplicationController.cs", true)
32 Process('Controller.cs', "${controllerPath}/${ControllerName}Controller.cs")
34 MkDir(controllerTestPath
)
35 Process('Test.cs', "${controllerTestPath}/${ControllerName}ControllerTest.cs")
37 MkDir(HelpersBasePath
)
38 Process('ScaffoldHelper.cs', "${HelpersBasePath}/ScaffoldHelper.cs", true)
41 Process("views/list.${ViewEngineExtension}", "${viewPath}/list.${ViewEngineExtension}")
42 Process("views/edit.${ViewEngineExtension}", "${viewPath}/edit.${ViewEngineExtension}")
43 Process("views/view.${ViewEngineExtension}", "${viewPath}/view.${ViewEngineExtension}")
44 Process("views/new.${ViewEngineExtension}", "${viewPath}/new.${ViewEngineExtension}")
45 Process("views/_form.${ViewEngineExtension}", "${viewPath}/_form.${ViewEngineExtension}")
47 MkDir("${ViewsBasePath}/layouts")
48 Process("views/layout.${ViewEngineExtension}", "${ViewsBasePath}/layouts/${ControllerFileName}.${ViewEngineExtension}")
50 MkDir("${StaticContentBasePath}/stylesheets")
51 Process('style.css', "${StaticContentBasePath}/stylesheets/scaffold.css", true)
54 return 'ModelName [[area/]controller]'
57 return 'Generates a CRUD actions controller for a specified model.'
61 return Controller
.ToClassName()
65 return Controller
.ToFileName()
70 return "${Area}/${ControllerFileName}"
71 return ControllerFileName
75 return _model
.ToClassName()
80 return "${ControllersNamespace}.${Area.ToClassName()}"
81 return ControllersNamespace
86 return "${ControllersTestsNamespace}.${Area.ToClassName()}"
87 return ControllersTestsNamespace
89 ApplicationControllerNamespace
:
91 return ControllersNamespace
95 return Config
.ModelsNamespace
99 return Config
.HelpersNamespace
103 return StaticContentBaseUrl
107 return Config
.ActionExtension