Skip to content

Commit 4bcda78

Browse files
author
Todd Lair
authored
Merge pull request #114 from marcdemz/bug/WIN-314
[Bug] WIN-314 - Environment variables should have higher priority
2 parents 61d69f9 + 54ec556 commit 4bcda78

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

Src/StackifyLib/Config.cs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -191,28 +191,6 @@ internal static string Get(string key, string defaultValue = null)
191191
{
192192
if (string.IsNullOrWhiteSpace(key) == false)
193193
{
194-
#if NETCORE || NETCOREX
195-
if (_configuration != null)
196-
{
197-
var appSettings = _configuration.GetSection("Stackify");
198-
v = appSettings[key.Replace("Stackify.", string.Empty)];
199-
200-
if (string.IsNullOrEmpty(v))
201-
{
202-
// Search in Retrace, but key will likely still be Stackify.name, not Retrace.name in the code
203-
var retraceAppSettings = _configuration.GetSection("Retrace");
204-
v = retraceAppSettings[key.Replace("Stackify.", string.Empty)];
205-
}
206-
}
207-
#endif
208-
209-
#if NETFULL
210-
if (string.IsNullOrEmpty(v))
211-
{
212-
v = System.Configuration.ConfigurationManager.AppSettings[key];
213-
}
214-
#endif
215-
216194
if (string.IsNullOrEmpty(v))
217195
{
218196
v = System.Environment.GetEnvironmentVariable(key);
@@ -233,6 +211,29 @@ internal static string Get(string key, string defaultValue = null)
233211
{
234212
v = System.Environment.GetEnvironmentVariable("RETRACE_" + key.Substring(9).Replace('.', '_').ToUpperInvariant());
235213
}
214+
215+
#if NETCORE || NETCOREX
216+
if (_configuration != null && string.IsNullOrEmpty(v))
217+
{
218+
var appSettings = _configuration.GetSection("Stackify");
219+
v = appSettings[key.Replace("Stackify.", string.Empty)];
220+
221+
if (string.IsNullOrEmpty(v))
222+
{
223+
// Search in Retrace, but key will likely still be Stackify.name, not Retrace.name in the code
224+
var retraceAppSettings = _configuration.GetSection("Retrace");
225+
v = retraceAppSettings[key.Replace("Stackify.", string.Empty)];
226+
}
227+
}
228+
#endif
229+
230+
#if NETFULL
231+
if (string.IsNullOrEmpty(v))
232+
{
233+
v = System.Configuration.ConfigurationManager.AppSettings[key];
234+
}
235+
#endif
236+
236237
}
237238
}
238239
finally

0 commit comments

Comments
 (0)