1
+ using System . Collections . Generic ;
2
+ using KY . Core . Dependency ;
3
+ using KY . Generator . Angular . Configurations ;
4
+ using KY . Generator . Angular . Writers ;
5
+ using KY . Generator . Command ;
6
+ using KY . Generator . Models ;
7
+ using KY . Generator . Output ;
8
+ using KY . Generator . Templates ;
9
+
10
+ namespace KY . Generator . Angular . Commands
11
+ {
12
+ internal class AngularModelCommand : IGeneratorCommand , IUseGeneratorCommandEnvironment
13
+ {
14
+ private readonly IDependencyResolver resolver ;
15
+ public string [ ] Names { get ; } = { "angular-model" } ;
16
+ public GeneratorEnvironment Environment { get ; set ; }
17
+
18
+ public AngularModelCommand ( IDependencyResolver resolver )
19
+ {
20
+ this . resolver = resolver ;
21
+ }
22
+
23
+ public bool Generate ( CommandConfiguration configuration , ref IOutput output )
24
+ {
25
+ AngularWriteConfiguration writeConfiguration = new AngularWriteConfiguration ( configuration ) ;
26
+ writeConfiguration . FormatNames = configuration . Parameters . GetBool ( nameof ( AngularWriteConfiguration . FormatNames ) , true ) ;
27
+ writeConfiguration . Model = new AngularWriteModelConfiguration ( ) ;
28
+ writeConfiguration . Model . Namespace = configuration . Parameters . GetString ( nameof ( AngularWriteModelConfiguration . Namespace ) ) ;
29
+ writeConfiguration . Model . RelativePath = configuration . Parameters . GetString ( nameof ( AngularWriteModelConfiguration . RelativePath ) ) ;
30
+ writeConfiguration . Model . SkipNamespace = configuration . Parameters . GetBool ( nameof ( AngularWriteModelConfiguration . SkipNamespace ) , true ) ;
31
+ writeConfiguration . Model . PropertiesToFields = configuration . Parameters . GetBool ( nameof ( AngularWriteModelConfiguration . PropertiesToFields ) , true ) ;
32
+ writeConfiguration . Model . FieldsToProperties = configuration . Parameters . GetBool ( nameof ( AngularWriteModelConfiguration . FieldsToProperties ) ) ;
33
+ writeConfiguration . Model . FormatNames = configuration . Parameters . GetBool ( nameof ( AngularWriteModelConfiguration . FormatNames ) , true ) ;
34
+
35
+ List < FileTemplate > files = new List < FileTemplate > ( ) ;
36
+ this . resolver . Create < AngularModelWriter > ( ) . Write ( writeConfiguration , this . Environment . TransferObjects , files ) ;
37
+ IOutput localOutput = output ;
38
+ files . ForEach ( file => writeConfiguration . Language . Write ( file , localOutput ) ) ;
39
+
40
+ return true ;
41
+ }
42
+ }
43
+ }
0 commit comments