@@ -35,46 +35,47 @@ public CreateCommand()
35
35
FileNameGenerator fileNameGenerator = new FileNameGenerator ( ) ;
36
36
TemplateCreator templateCreator = new TemplateCreator ( ) ;
37
37
APIVersionSetTemplateCreator apiVersionSetTemplateCreator = new APIVersionSetTemplateCreator ( templateCreator ) ;
38
+ ProductTemplateCreator productTemplateCreator = new ProductTemplateCreator ( templateCreator ) ;
38
39
ProductAPITemplateCreator productAPITemplateCreator = new ProductAPITemplateCreator ( ) ;
39
40
PolicyTemplateCreator policyTemplateCreator = new PolicyTemplateCreator ( fileReader ) ;
40
41
DiagnosticTemplateCreator diagnosticTemplateCreator = new DiagnosticTemplateCreator ( ) ;
41
42
APITemplateCreator apiTemplateCreator = new APITemplateCreator ( fileReader , templateCreator , policyTemplateCreator , productAPITemplateCreator , diagnosticTemplateCreator ) ;
42
43
MasterTemplateCreator masterTemplateCreator = new MasterTemplateCreator ( templateCreator ) ;
44
+ CreatorFileNames creatorFileNames = fileNameGenerator . GenerateCreatorLinkedFileNames ( creatorConfig ) ;
43
45
44
46
// create templates from provided configuration
45
47
Template apiVersionSetTemplate = creatorConfig . apiVersionSet != null ? apiVersionSetTemplateCreator . CreateAPIVersionSetTemplate ( creatorConfig ) : null ;
48
+ Template productsTemplate = creatorConfig . products != null ? productTemplateCreator . CreateProductTemplate ( creatorConfig ) : null ;
46
49
// store name and full template on each api necessary to build unlinked templates
47
50
Dictionary < string , Template > initialAPITemplates = new Dictionary < string , Template > ( ) ;
48
51
Dictionary < string , Template > subsequentAPITemplates = new Dictionary < string , Template > ( ) ;
49
52
// store name and whether the api will depend on the version set template each api necessary to build linked templates
50
- Dictionary < string , bool > apiInformation = new Dictionary < string , bool > ( ) ;
53
+ List < LinkedMasterTemplateAPIInformation > apiInformation = new List < LinkedMasterTemplateAPIInformation > ( ) ;
54
+ // create parameters file
55
+ Template masterTemplateParameters = masterTemplateCreator . CreateMasterTemplateParameterValues ( creatorConfig ) ;
51
56
52
57
foreach ( APIConfig api in creatorConfig . apis )
53
58
{
54
59
Template initialAPITemplate = await apiTemplateCreator . CreateInitialAPITemplateAsync ( creatorConfig , api ) ;
55
60
Template subsequentAPITemplate = apiTemplateCreator . CreateSubsequentAPITemplate ( api ) ;
56
61
initialAPITemplates . Add ( api . name , initialAPITemplate ) ;
57
62
subsequentAPITemplates . Add ( api . name , subsequentAPITemplate ) ;
58
- apiInformation . Add ( api . name , api . apiVersionSetId != null ) ;
63
+ apiInformation . Add ( new LinkedMasterTemplateAPIInformation ( )
64
+ {
65
+ name = api . name ,
66
+ dependsOnVersionSets = api . apiVersionSetId != null ,
67
+ dependsOnProducts = api . products != null ,
68
+ dependsOnLoggers = true
69
+ } ) ;
59
70
}
60
71
61
- CreatorFileNames creatorFileNames = fileNameGenerator . GenerateCreatorLinkedFileNames ( creatorConfig ) ;
62
- Template masterTemplateParameters = masterTemplateCreator . CreateMasterTemplateParameterValues ( creatorConfig ) ;
72
+ // write templates to outputLocation
63
73
if ( creatorConfig . linked == true )
64
74
{
65
75
// create linked master template
66
- Template masterTemplate = masterTemplateCreator . CreateLinkedMasterTemplate ( apiVersionSetTemplate , apiInformation , creatorFileNames , fileNameGenerator ) ;
67
- // write parameters to outputLocation
68
- fileWriter . WriteJSONToFile ( masterTemplateParameters , String . Concat ( creatorConfig . outputLocation , creatorFileNames . linkedParameters ) ) ;
69
- // write linked specific template to outputLocationc
76
+ Template masterTemplate = masterTemplateCreator . CreateLinkedMasterTemplate ( apiVersionSetTemplate , productsTemplate , apiInformation , creatorFileNames , fileNameGenerator ) ;
70
77
fileWriter . WriteJSONToFile ( masterTemplate , String . Concat ( creatorConfig . outputLocation , creatorFileNames . linkedMaster ) ) ;
71
78
}
72
- else
73
- {
74
- // write parameters to outputLocation
75
- fileWriter . WriteJSONToFile ( masterTemplateParameters , String . Concat ( creatorConfig . outputLocation , creatorFileNames . unlinkedParameters ) ) ;
76
- }
77
- // write templates to outputLocation
78
79
foreach ( KeyValuePair < string , Template > initialAPITemplatePair in initialAPITemplates )
79
80
{
80
81
string initialAPIFileName = fileNameGenerator . GenerateAPIFileName ( initialAPITemplatePair . Key , true ) ;
@@ -89,6 +90,12 @@ public CreateCommand()
89
90
{
90
91
fileWriter . WriteJSONToFile ( apiVersionSetTemplate , String . Concat ( creatorConfig . outputLocation , creatorFileNames . apiVersionSets ) ) ;
91
92
}
93
+ if ( productsTemplate != null )
94
+ {
95
+ fileWriter . WriteJSONToFile ( productsTemplate , String . Concat ( creatorConfig . outputLocation , creatorFileNames . products ) ) ;
96
+ }
97
+ // write parameters to outputLocation
98
+ fileWriter . WriteJSONToFile ( masterTemplateParameters , String . Concat ( creatorConfig . outputLocation , creatorConfig . linked == true ? creatorFileNames . linkedParameters : creatorFileNames . unlinkedParameters ) ) ;
92
99
ColoredConsole . WriteLine ( "Templates written to output location" ) ;
93
100
}
94
101
return 0 ;
0 commit comments