Пример #1
0
        public override Func <TwitterStatus, string> GetStringValueProvider()
        {
            var lsp = LeftValue.GetStringValueProvider();
            var rsp = RightValue.GetStringValueProvider();

            return(_ => lsp(_) + rsp(_));
        }
Пример #2
0
        public override Func <TwitterStatus, bool> GetBooleanValueProvider()
        {
            if (CompareAsString())
            {
                var haystack = LeftValue.GetStringValueProvider();
                var needle   = RightValue.GetStringValueProvider();
                return(t =>
                {
                    var h = haystack(t);
                    var n = needle(t);
                    if (h == null || n == null)
                    {
                        return false;
                    }
                    return h.IndexOf(n, GetStringComparison()) >= 0;
                });
            }
            var lsp = LeftValue.GetSetValueProvider();

            if (RightValue.SupportedTypes.Contains(FilterExpressionType.Numeric))
            {
                var rnp = RightValue.GetNumericValueProvider();
                return(_ => lsp(_).Contains(rnp(_)));
            }
            var rsp = RightValue.GetSetValueProvider();

            return(_ =>
            {
                var ls = lsp(_);
                return rsp(_).Any(ls.Contains);
            });
        }
Пример #3
0
        public override Func <TwitterStatus, bool> GetBooleanValueProvider()
        {
            // pre-check regular expressions
            var sv = this.RightValue as StringValue;

            if (sv != null)
            {
                this.AssertRegex(sv);
                var haystack = LeftValue.GetStringValueProvider();
                // optimize by pre-compiling
                var needleRegex = new Regex(sv.Value, RegexOptions.Compiled);
                return(t =>
                {
                    var h = haystack(t);
                    if (h == null)
                    {
                        return false;
                    }
                    try
                    {
                        return needleRegex.IsMatch(h);
                    }
                    catch (ArgumentException)
                    {
                        // exception occured
                        return false;
                    }
                });
            }
            else
            {
                var haystack = LeftValue.GetStringValueProvider();
                var needle   = RightValue.GetStringValueProvider();
                return(t =>
                {
                    var h = haystack(t);
                    var n = needle(t);
                    if (h == null || n == null)
                    {
                        return false;
                    }
                    try
                    {
                        return Regex.IsMatch(h, n);
                    }
                    catch (ArgumentException)
                    {
                        // exception occured
                        return false;
                    }
                });
            }
        }
Пример #4
0
        public override Func <TwitterStatus, bool> GetBooleanValueProvider()
        {
            var haystack = LeftValue.GetStringValueProvider();
            var needle   = RightValue.GetStringValueProvider();

            return(t =>
            {
                var h = haystack(t);
                var n = needle(t);
                if (h == null || n == null)
                {
                    return false;
                }
                return h.EndsWith(n, GetStringComparison());
            });
        }
Пример #5
0
        public override Func <TwitterStatus, bool> GetBooleanValueProvider()
        {
            switch (this.GetArgumentIntersectTypes())
            {
            case FilterExpressionType.Boolean:
                var lbp = LeftValue.GetBooleanValueProvider();
                var rbp = RightValue.GetBooleanValueProvider();
                return(_ => lbp(_) == rbp(_));

            case FilterExpressionType.Numeric:
                var lnp = LeftValue.GetNumericValueProvider();
                var rnp = RightValue.GetNumericValueProvider();
                return(_ => lnp(_) == rnp(_));

            case FilterExpressionType.String:
                var lsp = LeftValue.GetStringValueProvider();
                var rsp = RightValue.GetStringValueProvider();
                return(_ => String.Equals(lsp(_), rsp(_), GetStringComparison()));

            default:
                throw new InvalidOperationException("Invalid code path.");
            }
        }