本文整理汇总了C#中IMatcher.Matches方法的典型用法代码示例。如果您正苦于以下问题:C# IMatcher.Matches方法的具体用法?C# IMatcher.Matches怎么用?C# IMatcher.Matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMatcher
的用法示例。
在下文中一共展示了IMatcher.Matches方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WithForwardSlashes
public static IMatcher<string> WithForwardSlashes(IMatcher<string> matcher)
{
return Matchers.Function((string actual,IMatchDiagnostics diag) =>
{
if (actual != null)
{
actual = actual.Replace("\\", "/");
}
return matcher.Matches(actual, diag);
},
"ignoring slash type, " + matcher
);
}
示例2: As
// TODO:convert to use a generic type converter? Put into CoreMatchers?
/// <summary>
/// Attempt to parse the string to an int and apply the given int matcher
/// </summary>
/// <param name="intMatcher">The int matcher to match against</param>
/// <returns>A matcher on string</returns>
public static IMatcher<string> As(IMatcher<int?> intMatcher)
{
return Matchers.Function(
(string actual, IMatchDiagnostics diagnostics) =>
{
int intActual;
if (int.TryParse(actual, out intActual))
{
return intMatcher.Matches(intActual, diagnostics);
}
diagnostics.MisMatched("Couldn't parse the string '{0}' as an int", actual);
return false;
},
"string of int matching " + intMatcher);
}
示例3: DoFilter
private void DoFilter(IMatcher searchMatcher)
{
lvMembers.BeginUpdate();
try
{
lvMembers.Items.Clear();
foreach (ListViewItem item in archiveItems)
{
if (searchMatcher.Matches(item))
{
lvMembers.Items.Add(item);
}
}
}
finally
{
lvMembers.EndUpdate();
}
}
示例4: DoSearch
private void DoSearch(IMatcher searchMatcher)
{
int count = lvMembers.Items.Count;
int searchStartIdx = 0;
if (lvMembers.SelectedItems.Count > 0)
{
searchStartIdx = (lvMembers.SelectedIndices[0] + 1) % count;
}
int? searchResultIdx = null;
for (int i = 0; i < count; ++i)
{
int curIdx = (searchStartIdx + i) % count;
if (searchMatcher.Matches(lvMembers.Items[curIdx]))
{
searchResultIdx = curIdx;
break;
}
}
if (searchResultIdx != null)
{
lvMembers.Select();
lvMembers.Items[searchResultIdx.Value].Selected = true;
}
else
{
// Balloon is bugged on first invocation
errorBalloon.Show("Could not find search text", tbSearch);
errorBalloon.Show("Could not find search text", tbSearch);
}
}
示例5: TrimmedLength
public static IMatcher<string> TrimmedLength(IMatcher<int?> intMatcher)
{
return Matchers.Function(
(string actual, IMatchDiagnostics diagnostics) =>
{
actual = actual == null ? string.Empty : actual.Trim();
return intMatcher.Matches(actual.Length, diagnostics);
},
"string length " + intMatcher);
}
示例6: TraceMatch
private static bool TraceMatch(IMatcher baseMatcher, IMatcher targetMatcher, int depth)
{
bool isMatch = baseMatcher.Matches(targetMatcher);
DebugView.TraceEvent(IndentLevel.Matcher, () =>
String.Format("{3}: {0} -> \"{1}\" {4} \"{2}\"",
isMatch ? "Match" : "No match",
targetMatcher.DebugView,
baseMatcher.DebugView,
depth == 0 ? "this" : "arg " + depth,
isMatch ? "is" : "is not"));
return isMatch;
}