/// <summary> /// Visits the given expression. /// </summary> /// <param name="expression"> The expression to visit. </param> /// <returns> /// An Expression. /// </returns> public override Expression Visit(Expression expression) { var translatedExpression = _compositeExpressionFragmentTranslator.Translate(expression); if (translatedExpression != null && translatedExpression != expression) { return(Visit(translatedExpression)); } // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (expression != null && (expression.NodeType == ExpressionType.Convert || expression.NodeType == ExpressionType.Negate || expression.NodeType == ExpressionType.New)) { return(base.Visit(expression)); } var isTopLevelProjection = _isTopLevelProjection; _isTopLevelProjection = false; try { return(base.Visit(expression)); } finally { _isTopLevelProjection = isTopLevelProjection; } }
/// <summary> /// Delegates everything that is not fragments, converts, negates, and new with /// a top level return marker /// </summary> /// <param name="expression"></param> /// <returns></returns> public override Expression Visit(Expression expression) { var translated = _compositeExpressionFragmentTranslator.Translate(expression); if (translated != null && translated != expression) { return(Visit(translated)); } if (expression != null && (expression.NodeType == ExpressionType.Convert || expression.NodeType == ExpressionType.Negate || expression.NodeType == ExpressionType.New)) { return(base.Visit(expression)); } var isTopLevelReturn = _isTopLevelReturn; _isTopLevelReturn = false; try { return(base.Visit(expression)); } finally { _isTopLevelReturn = isTopLevelReturn; } }
/// <summary> /// 将表达式调度到此类中更专用的访问方法之一。 /// </summary> /// <returns> /// 如果修改了该表达式或任何子表达式,则为修改后的表达式;否则返回原始表达式。 /// </returns> /// <param name="expression">要访问的表达式。</param> public override Expression Visit(Expression expression) { var translatedExpression = _fragmentTranslator.Translate(expression); if (translatedExpression != null && translatedExpression != expression) { return(Visit(translatedExpression)); } return(base.Visit(expression)); }
public override Expression Visit(Expression expression) { var translatedExpression = _compositeExpressionFragmentTranslator.Translate(expression); if ((translatedExpression != null) && (translatedExpression != expression)) { return(Visit(translatedExpression)); } return(base.Visit(expression)); }