protected override bool TryGetHint(ExpressionParser parser, object left, object right, out string hint)
        {
            if (left is string && right is string)
            {
                if (((string)left).Equals((string)right, StringComparison.OrdinalIgnoreCase))   // TODO: think about ordinal vs culture-invariant here...
                {
                    hint = ", but would have been True if case-insensitive";
                    return(true);
                }

                hint = HintUtils.GetStringDifferHint((string)left, (string)right, StringComparer.CurrentCulture);
                return(hint != null);
            }

            hint = null;
            return(false);
        }
예제 #2
0
        public bool TryGetHint(ExpressionParser parser, Expression expression, out string hint)
        {
            var methE = expression as MethodCallExpression;

            if (methE != null)
            {
                if (StringEqualsMethodInfo.Any(x => x == methE.Method))
                {
                    var obj = parser.DynamicInvoke(methE.Object);
                    var arg = parser.DynamicInvoke(methE.Arguments.First());

                    var comparison = (StringComparison)(methE.Arguments.Select(parser.DynamicInvoke)
                                                        .FirstOrDefault(x => x is StringComparison) ?? StringComparison.CurrentCulture);

                    hint = HintUtils.GetStringDifferHint((string)obj, (string)arg, GetComparerFromComparison(comparison));
                    return(hint != null);
                }
            }

            hint = null;
            return(false);
        }