public StringTestEntry(string str, StringMatchMode mode, bool caseInvariant) { _str = caseInvariant ? str.ToLowerInvariant() : str; _mode = mode; _strAsDouble = AsDouble(_str); _strAsBool = AsBool(_str); }
public StringTestEntry(string str, StringMatchMode mode) { _str = str.ToLowerInvariant(); _mode = mode; _strAsDouble = AsDouble(_str); _strAsBool = AsBool(_str); }
public Criterion(string propertyName, CriteriaOperator @operator, object value, StringMatchMode matchMode, bool caseInsensitive) : this(propertyName, @operator, value) { if (@operator != CriteriaOperator.Like && @operator != CriteriaOperator.NotLike) throw new ArgumentException(); this.matchMode = matchMode; this.caseInsensitive = caseInsensitive; }
public Criterion(string propertyName, CriteriaOperator @operator, object value, StringMatchMode matchMode, bool caseInsensitive) : this(propertyName, @operator, value) { if (@operator != CriteriaOperator.Like && @operator != CriteriaOperator.NotLike) { throw new ArgumentException(); } this.matchMode = matchMode; this.caseInsensitive = caseInsensitive; }
private static string PrepareQuery(string query, StringMatchMode mode) { var result = new StringBuilder((int)(query.Length * 1.2 + 2)); result.Append(mode != StringMatchMode.IncludedWithin ? @"^" : @"\b"); for (var i = 0; i < query.Length; i++) { var c = query[i]; if (c == '\\') { var n = i + 1 < query.Length ? query[i + 1] : (char)0; if (IsQuerySymbol(n)) { i++; AppendEscaped(n, result); continue; } } if (c == '*') { result.Append(".*"); } else if (c == '?') { result.Append("."); } else { AppendEscaped(query[i], result); } } if (mode == StringMatchMode.CompleteMatch) { result.Append(@"$"); } return(result.ToString()); }
private MatchMode convertMatchMode(StringMatchMode stringMatchMode) { switch (stringMatchMode) { case StringMatchMode.Exact: return(MatchMode.Exact); case StringMatchMode.Anywhere: return(MatchMode.Anywhere); case StringMatchMode.Start: return(MatchMode.Start); case StringMatchMode.End: return(MatchMode.End); default: throw new ArgumentException("Invalid argument.", "stringMatchMode"); } }
private static ITestEntry CreateTestEntry(string value, RegexFactory regexFactory, StringMatchMode mode) { if (value.Length > 1) { if (value[0] == '"' && value[value.Length - 1] == '"') { return(new StringTestEntry(value.Substring(1, value.Length - 2), mode)); } if (value[0] == '\'' && value[value.Length - 1] == '\'') { return(new StringTestEntry(value.Substring(1, value.Length - 2), StringMatchMode.CompleteMatch)); } if (value[0] == '`' && value[value.Length - 1] == '`') { try { var regex = new Regex(value.Substring(1, value.Length - 2), RegexOptions.Compiled | RegexOptions.IgnoreCase); return(new RegexTestEntry(regex)); } catch (Exception) { return(new ConstTestEntry(false)); } } } if (RegexFromQuery.IsQuery(value)) { return(new RegexTestEntry(regexFactory(value, mode))); } return(new StringTestEntry(value, mode)); }
public StringMatcher(string matcher, StringMatchMode matchMode = StringMatchMode.Contains) { this.matchMode = matchMode; this.matcher = matcher; }
public static Regex Create(string query, StringMatchMode mode, bool ignoreCase) { return(new Regex(PrepareQuery(query, mode), ignoreCase ? RegexOptions.Compiled | RegexOptions.IgnoreCase : RegexOptions.Compiled)); }
private MatchMode convertMatchMode(StringMatchMode stringMatchMode) { switch (stringMatchMode) { case StringMatchMode.Exact: return MatchMode.Exact; case StringMatchMode.Anywhere: return MatchMode.Anywhere; case StringMatchMode.Start: return MatchMode.Start; case StringMatchMode.End: return MatchMode.End; default: throw new ArgumentException("Invalid argument.", "stringMatchMode"); } }
public StringMatcher(string matcher, StringMatchMode matchMode = StringMatchMode.Contains) { this.matchMode = matchMode; this.matcher = matcher; }
public StringMatchArguments(StringMatchMode mode, string value, bool ignoreCase) { this.Mode = mode; this.Value = value; this.IgnoreCase = ignoreCase; }