From f486f6423a5b451090cd90b4f4eed1ce0b7ae474 Mon Sep 17 00:00:00 2001 From: Paul Marvin Date: Wed, 7 Feb 2018 14:57:45 -0600 Subject: [PATCH] RT-751: StackifyLib.Config.LoadSettings overrides any explicit ApiKey, AppName, or Environment set programmatically fixes #67 --- Src/StackifyLib/Config.cs | 24 ++++++++++++------------ Src/StackifyLib/StackifyLib.csproj | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Src/StackifyLib/Config.cs b/Src/StackifyLib/Config.cs index 2874864..93a79cf 100644 --- a/Src/StackifyLib/Config.cs +++ b/Src/StackifyLib/Config.cs @@ -11,7 +11,7 @@ namespace StackifyLib /// public class Config { - #if NETCORE || NETCOREX +#if NETCORE || NETCOREX private static Microsoft.Extensions.Configuration.IConfigurationRoot _configuration = null; @@ -20,7 +20,7 @@ public static void SetConfiguration(Microsoft.Extensions.Configuration.IConfigur _configuration = configuration; } - #endif +#endif static Config() { @@ -31,21 +31,21 @@ public static void LoadSettings() { try { - CaptureErrorPostdata = Get("Stackify.CaptureErrorPostdata", string.Empty).Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase); + CaptureErrorPostdata = Get("Stackify.CaptureErrorPostdata", bool.FalseString).Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase); - CaptureServerVariables = Get("Stackify.CaptureServerVariables", string.Empty).Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase); + CaptureServerVariables = Get("Stackify.CaptureServerVariables", bool.FalseString).Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase); - CaptureSessionVariables = Get("Stackify.CaptureSessionVariables", string.Empty).Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase); + CaptureSessionVariables = Get("Stackify.CaptureSessionVariables", bool.FalseString).Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase); CaptureErrorHeaders = Get("Stackify.CaptureErrorHeaders", bool.TrueString).Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase); - CaptureErrorCookies = Get("Stackify.CaptureErrorCookies", string.Empty).Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase); + CaptureErrorCookies = Get("Stackify.CaptureErrorCookies", bool.FalseString).Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase); - ApiKey = Get("Stackify.ApiKey", string.Empty); + ApiKey = Get("Stackify.ApiKey", ApiKey ?? string.Empty); - AppName = Get("Stackify.AppName", string.Empty); + AppName = Get("Stackify.AppName", AppName ?? string.Empty); - Environment = Get("Stackify.Environment", string.Empty); + Environment = Get("Stackify.Environment", Environment ?? string.Empty); CaptureErrorHeadersWhitelist = Get("Stackify.CaptureErrorHeadersWhitelist", string.Empty); @@ -154,13 +154,13 @@ internal static string Get(string key, string defaultValue = null) try { - if (key != null) + if (string.IsNullOrWhiteSpace(key) == false) { #if NETCORE || NETCOREX if (_configuration != null) { var appSettings = _configuration.GetSection("Stackify"); - v = appSettings[key.Replace("Stackify.", "")]; + v = appSettings[key.Replace("Stackify.", string.Empty)]; } #endif @@ -168,7 +168,7 @@ internal static string Get(string key, string defaultValue = null) if (_configuration != null) { var appSettings = _configuration.GetSection("Stackify"); - v = appSettings[key.Replace("Stackify.", "")]; + v = appSettings[key.Replace("Stackify.", string.Empty)]; } #endif diff --git a/Src/StackifyLib/StackifyLib.csproj b/Src/StackifyLib/StackifyLib.csproj index 4329a42..7533c98 100644 --- a/Src/StackifyLib/StackifyLib.csproj +++ b/Src/StackifyLib/StackifyLib.csproj @@ -13,15 +13,15 @@ false false false - 2.1.1 + 2.1.2 StackifyLib https://github.com/stackify/stackify-api-dotnet https://github.com/stackify/stackify-api-dotnet/blob/master/LICENSE https://github.com/stackify/stackify-api-dotnet git https://stackify.com/wp-content/uploads/2017/02/stk.png - 2.1.1.0 - 2.1.1.0 + 2.1.2.0 + 2.1.2.0