public static bool ContainsMultiStringCall(Type batchType, Expression e) { var me = new SearchForMultiStringMethod(batchType); me.Visit(e); return(me.found); }
public static bool IsStaticRegexMatch(MethodCallExpression methodCall, Type batchType) { var calledMethod = methodCall.Method; // static bool System.Text.RegularExpressions.Regex.IsMatch(string input, string pattern) return(calledMethod.DeclaringType.Equals(typeof(System.Text.RegularExpressions.Regex)) && calledMethod.IsStatic && calledMethod.Name.Equals("IsMatch") && methodCall.Arguments.Count == 2 && methodCall.Arguments.All(a => a.Type.Equals(typeof(string))) && methodCall.Arguments.All(a => !SearchForMultiStringMethod.ContainsMultiStringCall(batchType, a)) && IsMemberOnBatchField(methodCall.Arguments.ElementAt(0) as MemberExpression, batchType)); }
protected override Expression VisitMethodCall(MethodCallExpression methodCall) { var calledMethod = methodCall.Method; // static bool System.Text.RegularExpressions.Regex.IsMatch(string input, string pattern) if (IsStaticRegexMatch(methodCall, this.batchType)) { return(methodCall); } if (!(calledMethod.DeclaringType.Equals(typeof(string)) && IsMemberOnBatchField(methodCall.Object as MemberExpression, this.batchType) && MultiStringHasVectorImplementation(calledMethod.Name) && IsMemberOnBatchField(methodCall.Object as MemberExpression, this.batchType) && methodCall.Arguments.Any(a => !SearchForMultiStringMethod.ContainsMultiStringCall(this.batchType, a)))) { this.IsVectorizable = false; } return(methodCall); }