所以我补充说
hierarchyRelation != null
作为条件。这是我正在调试的方法的局部变量,它是存在的。
“断点的条件未能执行。该条件为
条件必须计算为布尔运算”。单击“确定”停止
此断点。
实际上,条件更复杂,但这是再现问题的最简单情况。我尝试了变量,甚至比较了这个变量的属性,但它总是失败。
如果我尝试一个恒定条件,比如
1 != 2
或
1 = 1
它工作得很好。有什么问题吗?我发现的最相关的问题是
this
vb code
. 它的解决方案是直接在代码中添加调试方法。虽然我能做到,但我想知道为什么这不起作用。
private HierarchyNodeDto GetNodeTreeThatContainsText<TRollup, TLeaf, THierarchyRelation>(HierarchyNodeDto root, string text, PreFilter preFilter, Func<TLeaf, bool> leafContainsTextFunc, bool parentContainsText) where TRollup: HierarchyNodeDto where TLeaf: HierarchyNodeDto {
dynamic rootNode = root as TRollup;
if (rootNode != null) {
if (rootNode.Nodes == null) {
return null;
}
var childNodesWithText = new List<THierarchyRelation>();
foreach (var hierarchyRelation in rootNode.Nodes) {
var isLeaf = hierarchyRelation.Node.GetType() == typeof(TransactionTypeHierarchyLeafDto) || hierarchyRelation.Node.GetType() == typeof(AccountHierarchyLeafDto);
if (!isLeaf && hierarchyRelation.Node.Name != null && hierarchyRelation.Node.Name.ToLower().Contains(text) && preFilter != PreFilter.Leafs) {
childNodesWithText.Add(hierarchyRelation);
continue;
}
var subtreeThatContainsText = this.GetNodeTreeThatContainsText<TRollup, TLeaf, THierarchyRelation>(hierarchyRelation.Node, text, preFilter, leafContainsTextFunc, rootNode.Name.ToLower().Contains(text));
if (subtreeThatContainsText == null) {
continue;
}
hierarchyRelation.Node = subtreeThatContainsText;
childNodesWithText.Add(hierarchyRelation);
}
rootNode.Nodes = childNodesWithText;
if (rootNode.Nodes.Count > 0 || (rootNode.Name.ToLower().Contains(text) && preFilter != PreFilter.Leafs)) {
return rootNode;
}
return null;
}
var rootLeaf = root as TLeaf;
return rootLeaf != null && ((leafContainsTextFunc.Invoke(rootLeaf) && preFilter != PreFilter.Nodes) || (parentContainsText && preFilter != PreFilter.Leafs)) ? rootLeaf : null;
}
我在
foreach