Skip to content

Commit 02420ff

Browse files
committed
A few improvements of multiple levens Fixed #1029
1 parent 971c700 commit 02420ff

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

FetchXmlBuilder/Builder/TreeNodeHelper.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,10 @@ public static void SetNodeText(TreeNode node, FetchXmlBuilder fxb, bool validate
166166
{
167167
text += " ";
168168
AttributeMetadata attrmeta = null;
169-
if (node.Parent != null)
169+
if (node.LocalEntityName() is string attentity && !string.IsNullOrEmpty(attentity))
170170
{
171-
var parent = node.Parent.Value("name");
172-
attrmeta = fxb.GetAttribute(parent, name);
173-
name = fxb.GetAttributeDisplayName(parent, name);
171+
attrmeta = fxb.GetAttribute(attentity, name);
172+
name = fxb.GetAttributeDisplayName(attentity, name);
174173
}
175174
if (!string.IsNullOrEmpty(agg) && !string.IsNullOrEmpty(name))
176175
{
@@ -217,12 +216,11 @@ public static void SetNodeText(TreeNode node, FetchXmlBuilder fxb, bool validate
217216
var val = node.Value("value");
218217
var valueOf = node.Value("valueof");
219218
var uiname = node.Value("uiname");
220-
if (node.Parent?.Parent != null)
219+
if (node.LocalEntityName() is string cndentity && !string.IsNullOrEmpty(cndentity))
221220
{
222-
var entity = node.Parent.Parent.Value("name");
223-
val = fxb.GetContitionValue(entity, attr, val);
224-
attr = fxb.GetAttributeDisplayName(entity, attr);
225-
valueOf = fxb.GetAttributeDisplayName(entity, valueOf);
221+
val = fxb.GetContitionValue(cndentity, attr, val);
222+
attr = fxb.GetAttributeDisplayName(cndentity, attr);
223+
valueOf = fxb.GetAttributeDisplayName(cndentity, valueOf);
226224
}
227225
if (!string.IsNullOrEmpty(ent))
228226
{
@@ -247,11 +245,10 @@ public static void SetNodeText(TreeNode node, FetchXmlBuilder fxb, bool validate
247245

248246
case "value":
249247
var value = node.Value("#text");
250-
if (node.Parent?.Parent?.Parent != null)
248+
if (node.LocalEntityName() is string valentity && !string.IsNullOrEmpty(valentity))
251249
{
252-
var entity = node.Parent.Parent.Parent.Value("name");
253250
var attr = node.Parent.Value("attribute");
254-
value = fxb.GetContitionValue(entity, attr, value);
251+
value = fxb.GetContitionValue(valentity, attr, value);
255252
}
256253
text += " " + value;
257254
break;
@@ -266,10 +263,9 @@ public static void SetNodeText(TreeNode node, FetchXmlBuilder fxb, bool validate
266263
}
267264
else if (!string.IsNullOrEmpty(attr))
268265
{
269-
if (!string.IsNullOrEmpty(attr) && node.Parent != null)
266+
if (node.LocalEntityName() is string ordentity && !string.IsNullOrEmpty(ordentity))
270267
{
271-
var parent = node.Parent.Value("name");
272-
attr = fxb.GetAttributeDisplayName(parent, attr);
268+
attr = fxb.GetAttributeDisplayName(ordentity, attr);
273269
}
274270
{
275271
text += " " + attr;

0 commit comments

Comments
 (0)