/// <summary> /// Determines whether [contains] [the specified expression]. /// </summary> /// <param name="expression">The expression.</param> /// <param name="subExpression">The sub expression.</param> /// <param name="skipLambdaSignatures">if set to <see langword="true" /> skip lambda signatures.</param> /// <returns></returns> public static bool Contains(Expression expression, Expression subExpression, bool skipLambdaSignatures) { if (ReferenceEquals(expression, null) || ReferenceEquals(subExpression, null)) { return(false); } FinderExpressionVisitor fev = new FinderExpressionVisitor(subExpression, skipLambdaSignatures); fev.Visit(expression); return(fev._found); }
/// <summary> /// Determines whether <paramref name="expression" /> uses <paramref name="subExpression">the sub-expression</paramref>. /// This will search everywhere except inside the signature of a <see cref="LambdaExpression"/>, which is useful for finding the /// usage of a parameter, without including the parameters of signatures. /// </summary> /// <param name="expression">The expression.</param> /// <param name="subExpression">The sub expression.</param> /// <returns><see langword="true"/> if found; otherwise <see langword="false"/>.</returns> public static bool Uses(this LambdaExpression expression, Expression subExpression) { if (ReferenceEquals(expression, subExpression)) { return(true); } if (ReferenceEquals(expression, null) || ReferenceEquals(subExpression, null)) { return(false); } return(FinderExpressionVisitor.Contains(expression, subExpression, true)); }