本文整理汇总了C#中Matcher.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# Matcher.Execute方法的具体用法?C# Matcher.Execute怎么用?C# Matcher.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matcher
的用法示例。
在下文中一共展示了Matcher.Execute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultipleSubDirsAfterFirstWildcardMatch_HasCorrectStem
public void MultipleSubDirsAfterFirstWildcardMatch_HasCorrectStem()
{
var matcher = new Matcher();
matcher.AddInclude("compiler/**/*.cs");
var directoryPath = Path.Combine(_context.RootPath, "src/project");
var results = matcher.Execute(new DirectoryInfoWrapper(new DirectoryInfo(directoryPath)));
var actual = results.Files.Select(match => match.Stem);
var expected = new string[] {
"preprocess/preprocess-source1.cs",
"preprocess/sub/preprocess-source2.cs",
"preprocess/sub/sub/preprocess-source3.cs",
"shared/shared1.cs",
"shared/sub/shared2.cs",
"shared/sub/sub/sharedsub.cs"
};
Assert.Equal(
expected.OrderBy(e => e),
actual.OrderBy(e => e),
StringComparer.OrdinalIgnoreCase);
}
示例2: ExecuteAndVerify
private void ExecuteAndVerify(Matcher matcher, string directoryPath, params string[] expectFiles)
{
directoryPath = Path.Combine(_context.RootPath, directoryPath);
var results = matcher.Execute(new DirectoryInfoWrapper(new DirectoryInfo(directoryPath)));
var actual = results.Files.Select(relativePath => Path.GetFullPath(Path.Combine(_context.RootPath, directoryPath, relativePath)));
var expect = expectFiles.Select(relativePath => Path.GetFullPath(Path.Combine(_context.RootPath, relativePath)));
AssertHelpers.SortAndEqual(expect, actual, StringComparer.OrdinalIgnoreCase);
}
示例3: StemCorrectWithDifferentWildCards
public void StemCorrectWithDifferentWildCards()
{
var matcher = new Matcher();
matcher.AddInclude("sub/*.cs");
matcher.AddInclude("**/*.cs");
var directoryPath = Path.Combine(_context.RootPath, "src/project");
var results = matcher.Execute(new DirectoryInfoWrapper(new DirectoryInfo(directoryPath)));
var actual = results.Files.Select(match => match.Stem);
var expected = new string[] {
"source1.cs",
"source2.cs",
"source3.cs",
"sub2/source4.cs",
"sub2/source5.cs",
"compiler/preprocess/preprocess-source1.cs",
"compiler/preprocess/sub/preprocess-source2.cs",
"compiler/preprocess/sub/sub/preprocess-source3.cs",
"compiler/shared/shared1.cs",
"compiler/shared/sub/shared2.cs",
"compiler/shared/sub/sub/sharedsub.cs"
};
Assert.Equal(
expected.OrderBy(e => e),
actual.OrderBy(e => e),
StringComparer.OrdinalIgnoreCase);
}