/// <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))); }
/// <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))); }
/// <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)))); }
/// <inheritdoc /> protected override bool IsMatch(string value, string input) { var exactStringMatcher = new ExactMatcher(MatchBehaviour.AcceptOnMatch, ThrowException, value); return(MatchScores.IsPerfect(exactStringMatcher.IsMatch(input))); }
/// <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)))); }
/// <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))); }
/// <inheritdoc cref="IObjectMatcher.IsMatch"/> public double IsMatch(object input) { bool equals = _object != null?Equals(_object, input) : _bytes.SequenceEqual((byte[])input); return(MatchScores.ToScore(equals)); }
/// <inheritdoc /> protected override bool IsMatch(string value, string input) { var wildcardStringMatcher = new WildcardMatcher(MatchBehaviour.AcceptOnMatch, value, IgnoreCase); return(MatchScores.IsPerfect(wildcardStringMatcher.IsMatch(input))); }