@@ -141,6 +141,8 @@ You can find detailed information about the usage guidelines for the `ConfigMerg
141
141
When the ` getSettings ` method is invoked without parameters, it returns entire application configuration. However, the ` getSettings `
142
142
method can be invoked using two optional parameters: ** ` key ` ** and ** ` defaultValue ` ** .
143
143
144
+ To specify returning value type you can add generic type in ` getSettings ` .
145
+
144
146
The following example shows how to read configuration settings using all available overloads of ` getSettings ` method.
145
147
146
148
#### anyclass.ts
@@ -156,42 +158,42 @@ export class AnyClass {
156
158
157
159
myMethodToGetUrl1a() {
158
160
// will retrieve 'http://localhost:8000'
159
- let url: string = this .config .getSettings (' system.applicationUrl' );
161
+ const url = this .config .getSettings < string > (' system.applicationUrl' );
160
162
}
161
163
162
164
myMethodToGetUrl1b() {
163
165
// will retrieve 'http://localhost:8000'
164
- let url: string = this .config .getSettings ([' system' , ' applicationUrl' ]);
166
+ const url = this .config .getSettings < string > ([' system' , ' applicationUrl' ]);
165
167
}
166
168
167
169
myMethodToGetUrl2a() {
168
170
// will retrieve 'http://localhost:8000'
169
- let url: string = this .config .getSettings (' system' ).applicationUrl ;
171
+ const url = this .config .getSettings < string > (' system' ).applicationUrl ;
170
172
}
171
173
172
174
myMethodToGetUrl2b() {
173
175
// will retrieve 'http://localhost:8000'
174
- let url: string = this .config .getSettings ().system .applicationUrl ;
176
+ const url = this .config .getSettings < string > ().system .applicationUrl ;
175
177
}
176
178
177
179
myMethodToGetUrl3a() {
178
180
// will throw an exception (system.non_existing is not in the application settings)
179
- let url: string = this .config .getSettings (' system.non_existing' );
181
+ const url = this .config .getSettings < string > (' system.non_existing' );
180
182
}
181
183
182
184
myMethodToGetUrl3b() {
183
185
// will retrieve 'no data' (system.non_existing is not in the application settings)
184
- let url: string = this .config .getSettings (' system.non_existing' , ' no data' );
186
+ const url = this .config .getSettings < string > (' system.non_existing' , ' no data' );
185
187
}
186
188
187
189
myMethodToGetSeo1() {
188
190
// will retrieve {"pageTitle":"Tweeting bird"}
189
- let seoSettings: string = this .config .getSettings (' seo' );
191
+ const seoSettings = this .config .getSettings < string > (' seo' );
190
192
}
191
193
192
194
myMethodToGetSeo1() {
193
195
// will retrieve {"pageTitle":"Tweeting bird"}
194
- let seoSettings: string = this .config .getSettings ().seo ;
196
+ const seoSettings = this .config .getSettings < string > ().seo ;
195
197
}
196
198
}
197
199
```
0 commit comments