public void GivenMemberInitsWhenComparedThenAreSimilarShouldReturnResult( MemberInitExpression source, MemberInitExpression target, bool areSimilar) { Assert.Equal(areSimilar, ExpressionSimilarity.AreSimilar(source, target)); }
/// <summary> /// Each value in the binding list must be similar. /// </summary> /// <typeparam name="T">The <see cref="Expression"/> type.</typeparam> /// <param name="member">The binding list child.</param> /// <returns>A value indicating whether or not the bindings are all similar.</returns> public static Expression <Func <T, T, bool> > MemberBindingsMustBeSimilar <T>( Func <T, IList <MemberBinding> > member) where T : Expression => (s, t) => ExpressionSimilarity.MemberBindingsAreSimilar(member(s), member(t));
/// <summary> /// Uses <see cref="ExpressionSimilarity"/> to determine similarity. /// </summary> /// <param name="source">The source <see cref="Expression"/>.</param> /// <param name="target">The target <see cref="Expression"/>.</param> /// <returns>A flag indicating whether the expressions are similar.</returns> public static bool IsSimilarTo( this Expression source, Expression target) => ExpressionSimilarity.AreSimilar(source, target);
/// <summary> /// Uses <see cref="ExpressionSimilarity"/> to determine if an <see cref="Expression"/> /// is part of another. /// </summary> /// <param name="source">The source <see cref="Expression"/>.</param> /// <param name="target">The target <see cref="Expression"/> to parse.</param> /// <returns>A flag indicating whether the source is part of the target.</returns> public static bool IsPartOf( this Expression source, Expression target) => ExpressionSimilarity.IsPartOf(source, target);
/// <summary> /// Determines whether the expression tree of the query is similar to the other query. /// </summary> /// <param name="source">The source <see cref="IQueryable"/>.</param> /// <param name="target">The target <see cref="IQueryable"/>.</param> /// <returns>A flag indicating whether the queries are similar.</returns> public static bool IsSimilarTo( this IQueryable source, IQueryable target) => ExpressionSimilarity.AreSimilar( source.Expression, target?.Expression);