当前位置: 首页>>代码示例>>C#>>正文


C# IMatcher.Matches方法代码示例

本文整理汇总了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
   );
 }
开发者ID:andreasetti,项目名称:TestFirst.Net,代码行数:13,代码来源:APath.cs

示例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);
        }
开发者ID:activelylazy,项目名称:TestFirst.Net,代码行数:22,代码来源:AString.cs

示例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();
			}
		}
开发者ID:henke37,项目名称:BizHawk,代码行数:19,代码来源:ArchiveChooser.cs

示例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);
			}
		}
开发者ID:henke37,项目名称:BizHawk,代码行数:31,代码来源:ArchiveChooser.cs

示例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);
 }
开发者ID:activelylazy,项目名称:TestFirst.Net,代码行数:10,代码来源:AString.cs

示例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;
		}
开发者ID:ArthurYiL,项目名称:JustMockLite,代码行数:14,代码来源:MatcherTreeNode.cs


注:本文中的IMatcher.Matches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。