11/*
2- * Copyright 2016 Systemic Pty Ltd
2+ * Copyright 2017 Systemic Pty Ltd
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1717using Sif . Framework . Model . Infrastructure ;
1818using System ;
1919using System . Configuration ;
20+ using System . IO ;
21+ using System . Reflection ;
22+ using System . Web . Hosting ;
2023
2124namespace Sif . Framework . Model . Settings
2225{
@@ -44,11 +47,11 @@ protected bool GetBooleanSetting(string key, bool defaultValue)
4447
4548 try
4649 {
47- value = Boolean . Parse ( setting . Value ) ;
50+ value = bool . Parse ( setting . Value ) ;
4851 }
4952 catch ( FormatException )
5053 {
51- string message = String . Format ( "The valid values for the {0 } setting are \" true\" or \" false\" . The value \" {1 }\" is not valid." , setting . Key , setting . Value ) ;
54+ string message = $ "The valid values for the { setting . Key } setting are \" true\" or \" false\" . The value \" { setting . Value } \" is not valid.";
5255 throw new ConfigurationErrorsException ( message ) ;
5356 }
5457
@@ -73,11 +76,11 @@ protected int GetIntegerSetting(string key, int defaultValue)
7376
7477 try
7578 {
76- value = Int32 . Parse ( setting . Value ) ;
79+ value = int . Parse ( setting . Value ) ;
7780 }
7881 catch ( FormatException )
7982 {
80- string message = String . Format ( "The value \" {1 }\" is not a valid integer for the {0} setting." , setting . Key , setting . Value ) ;
83+ string message = $ "The value \" { setting . Value } \" is not a valid integer for the { setting . Key } setting." ;
8184 throw new ConfigurationErrorsException ( message ) ;
8285 }
8386
@@ -120,7 +123,7 @@ protected string GetStringSetting(string key)
120123 /// </summary>
121124 protected ConfigFileBasedFrameworkSettings ( )
122125 {
123- string configurationFilePath = System . Web . Hosting . HostingEnvironment . MapPath ( "~/SifFramework.config" ) ;
126+ string configurationFilePath = HostingEnvironment . MapPath ( "~/SifFramework.config" ) ;
124127
125128 if ( configurationFilePath == null )
126129 {
@@ -133,14 +136,21 @@ protected ConfigFileBasedFrameworkSettings()
133136
134137 if ( ! configuration . HasFile )
135138 {
136- string message = String . Format ( "Missing configuration file {0}." , configurationFilePath ) ;
139+ string fullPath = Assembly . GetExecutingAssembly ( ) . Location ;
140+ exeConfigurationFileMap . ExeConfigFilename = Path . GetDirectoryName ( fullPath ) + "\\ SifFramework.config" ;
141+ configuration = ConfigurationManager . OpenMappedExeConfiguration ( exeConfigurationFileMap , ConfigurationUserLevel . None ) ;
142+ }
143+
144+ if ( ! configuration . HasFile )
145+ {
146+ string message = $ "Missing configuration file { configurationFilePath } .";
137147 throw new ConfigurationErrorsException ( message ) ;
138148 }
139149
140150 }
141151
142152 /// <summary>
143- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.ApplicationKey"/>
153+ /// <see cref="IFrameworkSettings.ApplicationKey"/>
144154 /// </summary>
145155 public string ApplicationKey
146156 {
@@ -153,7 +163,7 @@ public string ApplicationKey
153163 }
154164
155165 /// <summary>
156- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.AuthenticationMethod"/>
166+ /// <see cref="IFrameworkSettings.AuthenticationMethod"/>
157167 /// </summary>
158168 public string AuthenticationMethod
159169 {
@@ -166,7 +176,7 @@ public string AuthenticationMethod
166176 }
167177
168178 /// <summary>
169- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.CompressPayload"/>
179+ /// <see cref="IFrameworkSettings.CompressPayload"/>
170180 /// </summary>
171181 public bool CompressPayload
172182 {
@@ -179,7 +189,7 @@ public bool CompressPayload
179189 }
180190
181191 /// <summary>
182- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.ConsumerName"/>
192+ /// <see cref="IFrameworkSettings.ConsumerName"/>
183193 /// </summary>
184194 public string ConsumerName
185195 {
@@ -192,7 +202,7 @@ public string ConsumerName
192202 }
193203
194204 /// <summary>
195- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.DataModelNamespace"/>
205+ /// <see cref="IFrameworkSettings.DataModelNamespace"/>
196206 /// </summary>
197207 public string DataModelNamespace
198208 {
@@ -205,7 +215,7 @@ public string DataModelNamespace
205215 }
206216
207217 /// <summary>
208- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.InfrastructureNamespace"/>
218+ /// <see cref="IFrameworkSettings.InfrastructureNamespace"/>
209219 /// </summary>
210220 public string InfrastructureNamespace
211221 {
@@ -218,7 +228,7 @@ public string InfrastructureNamespace
218228 }
219229
220230 /// <summary>
221- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.DeleteOnUnregister"/>
231+ /// <see cref="IFrameworkSettings.DeleteOnUnregister"/>
222232 /// </summary>
223233 public bool DeleteOnUnregister
224234 {
@@ -231,7 +241,7 @@ public bool DeleteOnUnregister
231241 }
232242
233243 /// <summary>
234- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.EnvironmentType"/>
244+ /// <see cref="IFrameworkSettings.EnvironmentType"/>
235245 /// </summary>
236246 public EnvironmentType EnvironmentType
237247 {
@@ -254,7 +264,7 @@ public EnvironmentType EnvironmentType
254264 }
255265 else
256266 {
257- string message = String . Format ( "The valid values for the {0 } setting are \" BROKERED\" or \" DIRECT\" . The value \" {1 }\" is not valid." , setting . Key , setting . Value ) ;
267+ string message = $ "The valid values for the { setting . Key } setting are \" BROKERED\" or \" DIRECT\" . The value \" { setting . Value } \" is not valid.";
258268 throw new ConfigurationErrorsException ( message ) ;
259269 }
260270
@@ -266,7 +276,7 @@ public EnvironmentType EnvironmentType
266276 }
267277
268278 /// <summary>
269- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.EnvironmentUrl"/>
279+ /// <see cref="IFrameworkSettings.EnvironmentUrl"/>
270280 /// </summary>
271281 public string EnvironmentUrl
272282 {
@@ -279,7 +289,7 @@ public string EnvironmentUrl
279289 }
280290
281291 /// <summary>
282- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.InstanceId"/>
292+ /// <see cref="IFrameworkSettings.InstanceId"/>
283293 /// </summary>
284294 public string InstanceId
285295 {
@@ -292,7 +302,7 @@ public string InstanceId
292302 }
293303
294304 /// <summary>
295- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.NavigationPageSize"/>
305+ /// <see cref="IFrameworkSettings.NavigationPageSize"/>
296306 /// </summary>
297307 public int NavigationPageSize
298308 {
@@ -305,7 +315,7 @@ public int NavigationPageSize
305315 }
306316
307317 /// <summary>
308- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.SharedSecret"/>
318+ /// <see cref="IFrameworkSettings.SharedSecret"/>
309319 /// </summary>
310320 public string SharedSecret
311321 {
@@ -318,7 +328,7 @@ public string SharedSecret
318328 }
319329
320330 /// <summary>
321- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.SolutionId"/>
331+ /// <see cref="IFrameworkSettings.SolutionId"/>
322332 /// </summary>
323333 public string SolutionId
324334 {
@@ -331,7 +341,7 @@ public string SolutionId
331341 }
332342
333343 /// <summary>
334- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.SupportedInfrastructureVersion"/>
344+ /// <see cref="IFrameworkSettings.SupportedInfrastructureVersion"/>
335345 /// </summary>
336346 public string SupportedInfrastructureVersion
337347 {
@@ -344,7 +354,7 @@ public string SupportedInfrastructureVersion
344354 }
345355
346356 /// <summary>
347- /// <see cref="Sif.Framework.Model.Settings. IFrameworkSettings.UserToken"/>
357+ /// <see cref="IFrameworkSettings.UserToken"/>
348358 /// </summary>
349359 public string UserToken
350360 {
@@ -390,5 +400,7 @@ public int JobTimeoutFrequency
390400 {
391401 get { return GetIntegerSetting ( SettingsPrefix + ".job.timeout.frequency" , 60 ) ; }
392402 }
403+
393404 }
405+
394406}
0 commit comments