Esempio n. 1
0
        /// <inheritdoc cref="IStringMatcher.IsMatch"/>
        public double IsMatch(string input)
        {
            double match = MatchScores.Mismatch;

            // Convert a single input string to a Queryable string-list with 1 entry.
            IQueryable queryable = new[] { input }.AsQueryable();

            try
            {
                // Use the Any(...) method to check if the result matches
                match = MatchScores.ToScore(_patterns.Select(pattern => queryable.Any(pattern.GetPattern())));

                return(MatchBehaviourHelper.Convert(MatchBehaviour, match));
            }
            catch
            {
                if (ThrowException)
                {
                    throw;
                }
            }

            return(MatchBehaviourHelper.Convert(MatchBehaviour, match));
        }
        /// <inheritdoc cref="IObjectMatcher.IsMatch"/>
        public double IsMatch(object input)
        {
            bool match = false;

            // When input is null or byte[], return Mismatch.
            if (input != null && !(input is byte[]))
            {
                try
                {
                    var inputAsJToken = ConvertValueToJToken(input);

                    match = DeepEquals(_valueAsJToken, inputAsJToken);
                }
                catch (JsonException)
                {
                    if (ThrowException)
                    {
                        throw;
                    }
                }
            }

            return(MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(match)));
        }
 private double IsMatch(JToken jtoken)
 {
     return(MatchScores.ToScore(_patterns.Select(pattern => jtoken.SelectToken(pattern.GetPattern()) != null)));
 }
Esempio n. 4
0
        /// <inheritdoc cref="IObjectMatcher.IsMatch"/>
        public double IsMatch(object input)
        {
            bool equals = ValueAsObject != null?Equals(ValueAsObject, input) : ValueAsBytes.SequenceEqual((byte[])input);

            return(MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(equals)));
        }
Esempio n. 5
0
 /// <inheritdoc cref="IStringMatcher.IsMatch"/>
 public double IsMatch(string input)
 {
     return(MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(_values.Select(value => value.Equals(input)))));
 }
        /// <inheritdoc cref="IStringMatcher.IsMatch"/>
        public double IsMatch(string input)
        {
            string jsonInput = "" + JsonConvert.DeserializeObject(input);

            return(MatchScores.ToScore(_jsons.Select(value => value.Equals(jsonInput))));
        }
Esempio n. 7
0
        /// <inheritdoc />
        protected override bool IsMatch(string value, string input)
        {
            var exactStringMatcher = new ExactMatcher(MatchBehaviour.AcceptOnMatch, ThrowException, value);

            return(MatchScores.IsPerfect(exactStringMatcher.IsMatch(input)));
        }
Esempio n. 8
0
        /// <inheritdoc cref="IStringMatcher.IsMatch"/>
        public double IsMatch(string input)
        {
            IStringMetric m = GetStringMetricType();

            return(MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(_patterns.Select(p => m.GetSimilarity(p, input)))));
        }
 /// <inheritdoc cref="IStringMatcher.IsMatch"/>
 public double IsMatch(string jsonInput)
 {
     System.Text.RegularExpressions.Regex patn = new System.Text.RegularExpressions.Regex(_regexes[0]);
     return(MatchScores.ToScore(_regexes.Select(patnvalue => (new System.Text.RegularExpressions.Regex(patnvalue)).IsMatch(jsonInput))));
 }
Esempio n. 10
0
 /// <inheritdoc cref="IStringMatcher.IsMatch"/>
 public double IsMatch(string input)
 {
     return(MatchScores.ToScore(_values.Select(value => value.Equals(input))));
 }
        /// <inheritdoc cref="IStringMatcher.IsMatch"/>
        public double IsMatch(string input)
        {
            var match = !string.IsNullOrEmpty(input);

            return(MatchBehaviourHelper.Convert(MatchBehaviour, MatchScores.ToScore(match)));
        }
Esempio n. 12
0
        /// <inheritdoc cref="IObjectMatcher.IsMatch"/>
        public double IsMatch(object input)
        {
            bool equals = _object != null?Equals(_object, input) : _bytes.SequenceEqual((byte[])input);

            return(MatchScores.ToScore(equals));
        }
Esempio n. 13
0
        /// <inheritdoc />
        protected override bool IsMatch(string value, string input)
        {
            var wildcardStringMatcher = new WildcardMatcher(MatchBehaviour.AcceptOnMatch, value, IgnoreCase);

            return(MatchScores.IsPerfect(wildcardStringMatcher.IsMatch(input)));
        }