Skip to content

Commit 349543d

Browse files
claudiamurialdoBeta Bot
authored andcommitted
Cherry pick branch 'genexuslabs:fix/getgxobject-cmpcontext-nullempty-match' into beta
1 parent 9fcbb76 commit 349543d

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

dotnet/src/dotnetframework/GxClasses/Core/Web/HttpAjaxContext.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,17 @@ private JObject GetGxObject(JArray array, String CmpContext, bool IsMasterPage)
286286
for (int i = 0; i < array.Count; i++)
287287
{
288288
obj = array.GetObject(i);
289-
if (obj["CmpContext"].ToString().Equals(CmpContext) && obj["IsMasterPage"].ToString().Equals(IsMasterPage.ToString()))
289+
string objCmpContext = obj["CmpContext"]?.ToString();
290+
string objIsMasterPage = obj["IsMasterPage"]?.ToString();
291+
// A missing/null/empty CmpContext on the array entry is equivalent to a null-or-empty parameter.
292+
bool cmpContextMatches = string.IsNullOrEmpty(objCmpContext)
293+
? string.IsNullOrEmpty(CmpContext)
294+
: objCmpContext.Equals(CmpContext);
295+
// A missing IsMasterPage on the array entry is treated as the default value (false).
296+
bool isMasterPageMatches = string.IsNullOrEmpty(objIsMasterPage)
297+
? !IsMasterPage
298+
: objIsMasterPage.Equals(IsMasterPage.ToString(), StringComparison.OrdinalIgnoreCase);
299+
if (cmpContextMatches && isMasterPageMatches)
290300
{
291301
return obj;
292302
}
@@ -303,7 +313,7 @@ private JObject GetGxObject(JArray array, String CmpContext, bool IsMasterPage)
303313
}
304314

305315
return null;
306-
}
316+
}
307317

308318
public void ajax_rsp_assign_attri(String CmpContext, bool IsMasterPage, String AttName, Object AttValue)
309319
{

0 commit comments

Comments
 (0)