Skip to content

Commit

Permalink
A few improvements of multiple levens Fixed #1029
Browse files Browse the repository at this point in the history
  • Loading branch information
rappen committed Apr 7, 2024
1 parent 971c700 commit 02420ff
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions FetchXmlBuilder/Builder/TreeNodeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,10 @@ public static void SetNodeText(TreeNode node, FetchXmlBuilder fxb, bool validate
{
text += " ";
AttributeMetadata attrmeta = null;
if (node.Parent != null)
if (node.LocalEntityName() is string attentity && !string.IsNullOrEmpty(attentity))
{
var parent = node.Parent.Value("name");
attrmeta = fxb.GetAttribute(parent, name);
name = fxb.GetAttributeDisplayName(parent, name);
attrmeta = fxb.GetAttribute(attentity, name);
name = fxb.GetAttributeDisplayName(attentity, name);
}
if (!string.IsNullOrEmpty(agg) && !string.IsNullOrEmpty(name))
{
Expand Down Expand Up @@ -217,12 +216,11 @@ public static void SetNodeText(TreeNode node, FetchXmlBuilder fxb, bool validate
var val = node.Value("value");
var valueOf = node.Value("valueof");
var uiname = node.Value("uiname");
if (node.Parent?.Parent != null)
if (node.LocalEntityName() is string cndentity && !string.IsNullOrEmpty(cndentity))
{
var entity = node.Parent.Parent.Value("name");
val = fxb.GetContitionValue(entity, attr, val);
attr = fxb.GetAttributeDisplayName(entity, attr);
valueOf = fxb.GetAttributeDisplayName(entity, valueOf);
val = fxb.GetContitionValue(cndentity, attr, val);
attr = fxb.GetAttributeDisplayName(cndentity, attr);
valueOf = fxb.GetAttributeDisplayName(cndentity, valueOf);
}
if (!string.IsNullOrEmpty(ent))
{
Expand All @@ -247,11 +245,10 @@ public static void SetNodeText(TreeNode node, FetchXmlBuilder fxb, bool validate

case "value":
var value = node.Value("#text");
if (node.Parent?.Parent?.Parent != null)
if (node.LocalEntityName() is string valentity && !string.IsNullOrEmpty(valentity))
{
var entity = node.Parent.Parent.Parent.Value("name");
var attr = node.Parent.Value("attribute");
value = fxb.GetContitionValue(entity, attr, value);
value = fxb.GetContitionValue(valentity, attr, value);
}
text += " " + value;
break;
Expand All @@ -266,10 +263,9 @@ public static void SetNodeText(TreeNode node, FetchXmlBuilder fxb, bool validate
}
else if (!string.IsNullOrEmpty(attr))
{
if (!string.IsNullOrEmpty(attr) && node.Parent != null)
if (node.LocalEntityName() is string ordentity && !string.IsNullOrEmpty(ordentity))
{
var parent = node.Parent.Value("name");
attr = fxb.GetAttributeDisplayName(parent, attr);
attr = fxb.GetAttributeDisplayName(ordentity, attr);
}
{
text += " " + attr;
Expand Down

0 comments on commit 02420ff

Please sign in to comment.