本文整理汇总了C#中RelativePath.CreateChild方法的典型用法代码示例。如果您正苦于以下问题:C# RelativePath.CreateChild方法的具体用法?C# RelativePath.CreateChild怎么用?C# RelativePath.CreateChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RelativePath
的用法示例。
在下文中一共展示了RelativePath.CreateChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PathIsExcluded
private bool PathIsExcluded(FullPath path)
{
var project = _projectDiscovery.GetProject(path);
if (project == null)
return true;
var rootPath = project.RootPath;
// If path is root itself, it is never excluded.
if (rootPath.Value.Length == path.Value.Length)
return false;
var rootLength = rootPath.Value.Length + 1; // Move past '\\' character.
if (rootPath.Value.Last() == Path.DirectorySeparatorChar)
rootLength--;
var relativePath = path.Value.Substring(rootLength);
var items = relativePath.Split(new char[] {
Path.DirectorySeparatorChar
});
var pathToItem = new RelativePath();
foreach (var item in items) {
var relativePathToItem = pathToItem.CreateChild(item);
if (!project.DirectoryFilter.Include(relativePathToItem))
return true;
// For the last component, we don't know if it is a file or directory.
// Be conservative and try both.
if (item == items.Last()) {
if (!project.FileFilter.Include(relativePathToItem))
return true;
}
pathToItem = relativePathToItem;
}
return false;
}
示例2: PathIsExcluded
private bool PathIsExcluded(PathChangeEntry change) {
var path = change.Path;
var project = _projectDiscovery.GetProject(path);
if (project == null)
return true;
// If path is root itself, it is never excluded.
if (path == project.RootPath)
return false;
// Split relative part into list of name components.
var split = PathHelpers.SplitPrefix(path.Value, project.RootPath.Value);
var relativePath = split.Suffix;
var names = relativePath.Split(Path.DirectorySeparatorChar);
// Check each relative path from root path to full path.
var pathToItem = new RelativePath();
foreach (var item in names) {
var relativePathToItem = pathToItem.CreateChild(item);
bool exclude;
// For the last component, we might not if it is a file or directory.
// Check depending on the change kind.
if (item == names.Last()) {
if (change.Kind == PathChangeKind.Deleted) {
exclude = false;
} else {
var info = _fileSystem.GetFileInfoSnapshot(path);
if (info.IsFile) {
exclude = !project.FileFilter.Include(relativePathToItem);
} else if (info.IsDirectory) {
exclude = !project.DirectoryFilter.Include(relativePathToItem);
} else {
// We don't know... Be conservative.
exclude = false;
}
}
} else {
exclude = !project.DirectoryFilter.Include(relativePathToItem);
}
if (exclude)
return true;
pathToItem = relativePathToItem;
}
return false;
}