From 5ef99a1e534251c417716848049abecedb074fbd Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 24 Oct 2024 06:15:57 -0400 Subject: [PATCH] Fix minor logic bug in SetField --- SabreTools.Core/Filter/FieldManipulator.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/SabreTools.Core/Filter/FieldManipulator.cs b/SabreTools.Core/Filter/FieldManipulator.cs index e1b8b288..2622d5fd 100644 --- a/SabreTools.Core/Filter/FieldManipulator.cs +++ b/SabreTools.Core/Filter/FieldManipulator.cs @@ -56,13 +56,18 @@ namespace SabreTools.Core.Filter if (dictionaryBase == null || string.IsNullOrEmpty(fieldName)) return false; - // Retrieve the list of valid fields for the item and validate + // Retrieve the list of valid fields for the item var constants = TypeHelper.GetConstants(dictionaryBase.GetType()); - if (constants == null || !constants.Any(c => string.Equals(c, fieldName, StringComparison.OrdinalIgnoreCase))) + if (constants == null) + return false; + + // Get the value that matches the field name provided + string? realField = constants.FirstOrDefault(c => string.Equals(c, fieldName, StringComparison.OrdinalIgnoreCase)); + if (realField == null) return false; // Set the field with the new value - dictionaryBase[fieldName!] = value; + dictionaryBase[realField] = value; return true; } }