本文整理汇总了C#中Tree.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Tree.Contains方法的具体用法?C# Tree.Contains怎么用?C# Tree.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree.Contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: op_Contains_Tree
public void op_Contains_Tree()
{
var expected = new Tree<int>();
var obj = new Tree<int>
{
expected
};
Assert.True(obj.Contains(expected));
}
示例2: CreateFolderTree
/// <summary>
/// generates a hierarchy of folder names from the archive.
/// </summary>
/// <returns></returns>
public Tree<String> CreateFolderTree(char pathSeperator)
{
Tree<String> tree = new Tree<string>();
TreeNode<String> parent = null;
// enumerate the actual directories:
foreach (string dir in GetDirectories())
{
// break the dir into folder-names:
string[] elements = dir.Split(pathSeperator);
// build the path folder at a time.
string path = "";
// enumerate the path elements
foreach (var pathElement in elements)
{
// append to the path variable
if (path.Length > 0)
path += pathSeperator;
path += pathElement;
if (parent != null)
{
// add the current path to the hierarchy under the parent.
if (!tree.Contains(path))
parent = tree.Add(path, parent);
else
parent = tree[path];
}
else
{
// add the current path to the top of the tree.
if (!tree.Contains(path))
parent = tree.Add(path);
else
parent = tree[path];
}
}
}
// return the populated tree.
return tree;
}