public void Two_node_path_parents_are_correct() { var path = new ExpressionNodePath(); var rootExp = new ClassifiedExpression(null); var childExp = new ClassifiedExpression(null); path.Insert(0, rootExp); Assert.AreEqual(null, path.Parent); path.Insert(0, childExp); Assert.AreEqual(rootExp, path.Parent); }
/// <summary> /// Analyses and transforms the supplied expression node /// </summary> /// <param name="node">Expression/node to be analysed</param> /// <returns>The transformed expression</returns> public override Expression Visit(Expression node) { var classifiedExpr = new ClassifiedExpression(node); _currentNodePath.Insert(0, classifiedExpr); try { // if we're under the main select, check with the analyser if the expression should be // passed on; if so, no need to visit children, just replace with a parameter if (this._currentNodePath.AncestorHasClassification <MainSelectCallClassification>()) { if (ShouldProviderHandleExpression(_currentNodePath)) { var sourceExpr = RegisterSourceExpression(0); return(sourceExpr.ParameterReplacement); } } // not a source experssion, keep processing.. var result = base.Visit(node); return(result); } finally { _currentNodePath.RemoveAt(0); } }