Пример #1
0
        /// <summary>
        /// Adds to the lambda expression a string match test on either a property name string or a property value string</summary>
        /// <param name="sourceStringExp">Expression that evaluates to the string on which this search is applied</param>
        /// <param name="matchString">String to match</param>
        /// <param name="searchType">Regular expression string search type</param>
        /// <param name="isReplacePattern">Whether or not this match should be used in a subsequent replace operation</param>
        public void AddStringSearchExpression(Expression sourceStringExp, string matchString, UInt64 searchType, bool isReplacePattern)
        {
            string     patternString    = CreateRegularExpressionPattern(matchString, searchType);
            Expression patternStringExp = Expression.Constant(patternString);

            if (isReplacePattern)
            {
                MatchPattern = new StringReplaceQueryPattern(patternString);
            }

            Expression           optionsExp     = Expression.Constant(RegexOptions.IgnoreCase, typeof(RegexOptions));
            MethodCallExpression regexMatchTest = Expression.Call(typeof(Regex), "Match", null, new Expression[3] {
                sourceStringExp, patternStringExp, optionsExp
            });
            MemberExpression regexSuccess = Expression.Property(regexMatchTest, "Success");

            AddExpression(
                Expression.OrElse(
                    GetNullOrEmptyExpression(matchString),
                    Expression.Equal(regexSuccess, Expression.Constant(true))));
        }
Пример #2
0
        /// <summary>
        /// Adds to the lambda expression a string match test on either a property name string or a property value string</summary>
        /// <param name="sourceStringExp">Expression that evaluates to the string on which this search is applied</param>
        /// <param name="matchString">String to match</param>
        /// <param name="searchType">Regular expression string search type</param>
        /// <param name="isReplacePattern">Whether or not this match should be used in a subsequent replace operation</param>
        public void AddStringSearchExpression(Expression sourceStringExp, string matchString, UInt64 searchType, bool isReplacePattern)
        {
            string patternString = CreateRegularExpressionPattern(matchString, searchType);
            Expression patternStringExp = Expression.Constant(patternString);
            if (isReplacePattern)
                MatchPattern = new StringReplaceQueryPattern(patternString);

            Expression optionsExp = Expression.Constant(RegexOptions.IgnoreCase, typeof(RegexOptions));
            MethodCallExpression regexMatchTest = Expression.Call(typeof(Regex), "Match", null, new Expression[3] { sourceStringExp, patternStringExp, optionsExp });
            MemberExpression regexSuccess = Expression.Property(regexMatchTest, "Success");
            AddExpression(
                Expression.OrElse(
                    GetNullOrEmptyExpression(matchString),
                    Expression.Equal(regexSuccess, Expression.Constant(true))));
        }