Disallow empty values in custom dictionaries

This commit is contained in:
Matt Nadareski
2024-12-02 16:31:19 -05:00
parent 8b10a7c3ea
commit 8570237fb3
2 changed files with 8 additions and 2 deletions

View File

@@ -13,7 +13,7 @@ namespace BinaryObjectScanner
/// <remarks>Handles the proper Add implementation</remarks>
public void Append(T key, string? value)
{
if (value == null)
if (value == null || value.Trim().Length == 0)
return;
#if NET20 || NET35

View File

@@ -24,7 +24,7 @@ namespace BinaryObjectScanner
public void Append(string key, string value)
{
// If the value is empty, don't add it
if (string.IsNullOrEmpty(value))
if (value == null || value.Trim().Length == 0)
return;
Append(key, [value]);
@@ -44,6 +44,9 @@ namespace BinaryObjectScanner
EnsureKey(key);
foreach (string value in values)
{
if (value == null || value.Trim().Length == 0)
continue;
this[key].Enqueue(value);
}
}
@@ -180,6 +183,9 @@ namespace BinaryObjectScanner
foreach (string value in values)
{
if (value == null || value.Trim().Length == 0)
continue;
this[key].Enqueue(value);
}
}