diff --git a/BurnOutSharp/Scanner.cs b/BurnOutSharp/Scanner.cs index fd672456..40b456d4 100644 --- a/BurnOutSharp/Scanner.cs +++ b/BurnOutSharp/Scanner.cs @@ -166,6 +166,9 @@ namespace BurnOutSharp } } + // Clear out any empty keys + Utilities.ClearEmptyKeys(protections); + return protections; } @@ -569,6 +572,9 @@ namespace BurnOutSharp #endregion } + // Clear out any empty keys + Utilities.ClearEmptyKeys(protections); + return protections; } } diff --git a/BurnOutSharp/Utilities.cs b/BurnOutSharp/Utilities.cs index 49418237..9132bfef 100644 --- a/BurnOutSharp/Utilities.cs +++ b/BurnOutSharp/Utilities.cs @@ -67,6 +67,31 @@ namespace BurnOutSharp } } + /// + /// Remove empty or null keys from a results dictionary + /// + /// Dictionary to clean + public static void ClearEmptyKeys(Dictionary> original) + { + // If the dictionary is missing, we can't do anything + if (original == null) + return; + + // Get a list of all of the keys + var keys = original.Keys.ToList(); + + // Iterate and reset keys + for (int i = 0; i < keys.Count; i++) + { + // Get the current key + string key = keys[i]; + + // If the key is empty, remove it + if (original[key] == null || !original[key].Any()) + original.Remove(key); + } + } + /// /// Prepend a parent path from dictionary keys, if possible ///