(bugfix): TryGetOperation case insensitive dictionary keys

This commit is contained in:
Maksym Sadovnychyy 2024-12-15 13:04:06 +01:00
parent 7cddda23e6
commit c5bf11270f
2 changed files with 4 additions and 5 deletions

View File

@ -23,15 +23,14 @@ public abstract class PatchRequestModelBase : RequestModelBase {
/// <param name="operation">When this method returns, contains the patch operation associated with the specified property name, if the key is found; otherwise, null.</param> /// <param name="operation">When this method returns, contains the patch operation associated with the specified property name, if the key is found; otherwise, null.</param>
/// <returns>true if the patch operation is found; otherwise, false.</returns> /// <returns>true if the patch operation is found; otherwise, false.</returns>
public bool TryGetOperation(string propertyName, [NotNullWhen(true)] out PatchOperation? operation) { public bool TryGetOperation(string propertyName, [NotNullWhen(true)] out PatchOperation? operation) {
propertyName = propertyName.ToLower();
if (Operations == null) { if (Operations == null) {
operation = null; operation = null;
return false; return false;
} }
if (Operations.TryGetValue(propertyName, out var tempOperation)) { var entry = Operations.FirstOrDefault(op => op.Key.Equals(propertyName, StringComparison.OrdinalIgnoreCase));
operation = tempOperation; if (!entry.Equals(default(KeyValuePair<string, PatchOperation>))) {
operation = entry.Value;
return true; return true;
} }
else { else {

View File

@ -8,7 +8,7 @@
<!-- NuGet package metadata --> <!-- NuGet package metadata -->
<PackageId>MaksIT.Core</PackageId> <PackageId>MaksIT.Core</PackageId>
<Version>1.2.7</Version> <Version>1.2.8</Version>
<Authors>Maksym Sadovnychyy</Authors> <Authors>Maksym Sadovnychyy</Authors>
<Company>MAKS-IT</Company> <Company>MAKS-IT</Company>
<Product>MaksIT.Core</Product> <Product>MaksIT.Core</Product>