本文整理汇总了C#中Tree.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.ToList方法的具体用法?C# Tree.ToList怎么用?C# Tree.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree.ToList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TraverseTree
protected static IEnumerable<string> TraverseTree(Tree tree)
{
foreach (TreeEntry item in tree.ToList())
{
if (item.TargetType == TreeEntryTargetType.Blob)
{
var blob = (Blob)item.Target;
yield return (item.Path);
}
if (item.TargetType == TreeEntryTargetType.Tree)
{
var subTree = (Tree)item.Target;
foreach (var result in TraverseTree(subTree))
{
yield return result;
}
}
}
}
示例2: FindPath
public static void FindPath(Tree<int> currentNode, List<Tree<int>> currentPath) {
if (currentNode.Children.Count == 0)
{
allPaths.Push(currentPath);
return;
}
else
{
foreach (var child in currentNode.Children)
{
Tree<int>[] newPathArray = new Tree<int>[currentPath.Count];
currentPath.CopyTo(newPathArray);
List<Tree<int>> newPath = newPathArray.ToList();
newPath.Add(child);
FindPath(child, newPath);
}
}
}
示例3: GetTreeModelsWithDetails
private IEnumerable<RepositoryTreeDetailModel> GetTreeModelsWithDetails(Commit commit, Tree tree, string referenceName)
{
var ancestors = _repository.Commits.QueryBy(new CommitFilter { Since = commit, SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Reverse }).ToList();
var entries = tree.ToList();
var result = new List<RepositoryTreeDetailModel>();
for (int i = 0; i < ancestors.Count && entries.Any(); i++)
{
var ancestor = ancestors[i];
for (int j = 0; j < entries.Count; j++)
{
var entry = entries[j];
var ancestorEntry = ancestor[entry.Path];
if (ancestorEntry != null && entry.Target.Sha == ancestorEntry.Target.Sha)
{
result.Add(CreateRepositoryDetailModel(entry, ancestor, referenceName));
entries[j] = null;
}
}
entries.RemoveAll(entry => entry == null);
}
return result;
}