mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix minor logic bug in SetField
This commit is contained in:
@@ -56,13 +56,18 @@ namespace SabreTools.Core.Filter
|
|||||||
if (dictionaryBase == null || string.IsNullOrEmpty(fieldName))
|
if (dictionaryBase == null || string.IsNullOrEmpty(fieldName))
|
||||||
return false;
|
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());
|
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;
|
return false;
|
||||||
|
|
||||||
// Set the field with the new value
|
// Set the field with the new value
|
||||||
dictionaryBase[fieldName!] = value;
|
dictionaryBase[realField] = value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user