本文整理汇总了C#中ProjectManager.ParentOf方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectManager.ParentOf方法的具体用法?C# ProjectManager.ParentOf怎么用?C# ProjectManager.ParentOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectManager
的用法示例。
在下文中一共展示了ProjectManager.ParentOf方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GroupTaskLevelAndOrdering
public void GroupTaskLevelAndOrdering()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var zero = new Task() { Name = "zero" };
var one = new Task() { Name = "one" };
var two = new Task() { Name = "two" };
var three = new Task() { Name = "three" };
var four = new Task() { Name = "four" };
var five = new Task() { Name = "five" };
manager.Add(zero);
manager.Add(one);
manager.Add(two);
manager.Add(three);
manager.Add(four);
manager.Add(five);
// single level ordering
Assert.IsTrue(manager.IndexOf(zero) == 0);
Assert.IsTrue(manager.IndexOf(one) == 1);
Assert.IsTrue(manager.IndexOf(two) == 2);
Assert.IsTrue(manager.IndexOf(three) == 3);
Assert.IsTrue(manager.IndexOf(four) == 4);
Assert.IsTrue(manager.IndexOf(five) == 5);
Assert.IsTrue(manager.Tasks.Count() == 6);
// two level ordering
manager.Group(zero, two);
manager.Group(zero, three);
Assert.IsTrue(manager.IndexOf(zero) == 0);
Assert.IsTrue(manager.IndexOf(two) == 1);
Assert.IsTrue(manager.IndexOf(three) == 2);
Assert.IsTrue(manager.IndexOf(one) == 3);
Assert.IsTrue(manager.IndexOf(four) == 4);
Assert.IsTrue(manager.IndexOf(five) == 5);
Assert.IsTrue(manager.Tasks.Count() == 6);
// three level ordering
manager.Group(five, zero);
Assert.IsTrue(manager.IndexOf(one) == 0);
Assert.IsTrue(manager.IndexOf(four) == 1);
Assert.IsTrue(manager.IndexOf(five) == 2, string.Format("Assert index == {0}; but index == {1}", 0, manager.IndexOf(five)));
Assert.IsTrue(manager.IndexOf(zero) == 3);
Assert.IsTrue(manager.IndexOf(two) == 4);
Assert.IsTrue(manager.IndexOf(three) == 5);
Assert.IsTrue(manager.Tasks.Count() == 6);
// twin three level ordering
manager.Group(four, one);
Assert.IsTrue(manager.IndexOf(four) == 0);
Assert.IsTrue(manager.IndexOf(one) == 1);
Assert.IsTrue(manager.IndexOf(five) == 2, string.Format("Assert index == {0}; but index == {1}", 0, manager.IndexOf(five)));
Assert.IsTrue(manager.IndexOf(zero) == 3);
Assert.IsTrue(manager.IndexOf(two) == 4);
Assert.IsTrue(manager.IndexOf(three) == 5);
Assert.IsTrue(manager.Tasks.Count() == 6);
// four level ordering
manager.Group(two, four);
Assert.IsTrue(manager.IndexOf(five) == 0, string.Format("Assert index == {0}; but index == {1}", 0, manager.IndexOf(five)));
Assert.IsTrue(manager.IndexOf(zero) == 1);
Assert.IsTrue(manager.IndexOf(two) == 2);
Assert.IsTrue(manager.IndexOf(four) == 3);
Assert.IsTrue(manager.IndexOf(one) == 4);
Assert.IsTrue(manager.IndexOf(three) == 5);
Assert.IsTrue(manager.Tasks.Count() == 6, string.Format("{0} != {1}", 6, manager.Tasks.Count()));
// check parents
Assert.IsTrue(manager.ParentOf(zero).Equals(five));
Assert.IsTrue(manager.ParentOf(one).Equals(four));
Assert.IsTrue(manager.ParentOf(two).Equals(zero));
Assert.IsTrue(manager.ParentOf(three).Equals(zero));
Assert.IsTrue(manager.ParentOf(four).Equals(two));
Assert.IsTrue(manager.ParentOf(five) == null);
}
示例2: GroupIntoParent
public void GroupIntoParent()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var group1 = new Task();
var one = new Task();
manager.Add(group1);
manager.Add(one);
// setup: group1 contains one
manager.Group(group1, one);
// test: grouping into parent (no effect, since already grouped)
manager.Group(one, group1);
Assert.IsTrue(manager.IsGroup(group1));
Assert.IsTrue(!manager.IsGroup(one));
Assert.IsTrue(manager.ParentOf(one).Equals(group1));
}
示例3: GroupIntoSelf
public void GroupIntoSelf()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var group1 = new Task();
// test: group into self (no effect)
manager.Group(group1, group1);
Assert.IsTrue(!manager.IsGroup(group1));
Assert.IsTrue(manager.ParentOf(group1) == null);
}
示例4: GroupIntoChild
public void GroupIntoChild()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var group1 = new Task();
var one = new Task();
manager.Add(group1);
manager.Add(one);
// setup: group1 contains one
manager.Group(group1, one);
// test: group into child (no effect)
manager.Group(one, group1);
Assert.IsTrue(manager.DecendantsOf(group1).Contains(one));
Assert.IsTrue(manager.ParentOf(one).Equals(group1));
Assert.IsTrue(manager.ParentOf(group1) == null);
}
示例5: GroupIntoGrandParent
public void GroupIntoGrandParent()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var group1 = new Task();
var group2 = new Task();
var one = new Task();
manager.Add(group1);
manager.Add(group2);
manager.Add(one);
// setup: group1 contain group2 contain one
manager.Group(group1, group2);
manager.Group(group2, one);
// test: group into grandparent (allowed)
manager.Group(group1, one);
Assert.IsTrue(manager.IsGroup(group1));
Assert.IsTrue(!manager.IsGroup(group2));
Assert.IsTrue(!manager.IsGroup(one));
Assert.IsTrue(manager.ParentOf(one).Equals(group1));
Assert.IsTrue(manager.ParentOf(group2).Equals(group1));
Assert.IsTrue(manager.ParentOf(group1) == null);
}
示例6: GroupIntoAnotherGroupWhenAlreadyHaveGroup
public void GroupIntoAnotherGroupWhenAlreadyHaveGroup()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var group1 = new Task();
var group2 = new Task();
var one = new Task();
manager.Add(group1);
manager.Add(group2);
manager.Add(one);
// setup: group1 contains one
manager.Group(group1, one);
// test: group one into group2, leaving group1
manager.Group(group2, one);
Assert.IsTrue(!manager.IsGroup(group1), string.Format("{0} != {1}", true, manager.IsGroup(group1)));
Assert.IsTrue(manager.IsGroup(group2));
Assert.IsTrue(!manager.IsGroup(one));
Assert.IsTrue(manager.ParentOf(one).Equals(group2));
Assert.IsTrue(manager.ChildrenOf(group1).Count() == 0);
Assert.IsTrue(manager.ChildrenOf(group2).Count() == 1);
}
示例7: GroupChildIntoSelf
public void GroupChildIntoSelf()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var group1 = new Task();
var one = new Task();
manager.Add(group1);
manager.Add(one);
// setup: group1 contain group2 contain one
manager.Group(group1, one);
// test: group into self (no effect)
manager.Group(one, one);
Assert.IsTrue(!manager.IsGroup(one));
Assert.IsTrue(manager.ParentOf(one) == group1);
}
示例8: CreateAndRemoveTask
public void CreateAndRemoveTask()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
// create first task
var first = new Task();
manager.Add(first);
Assert.IsTrue(manager.Tasks.Count() == 1, string.Format("{0} != {1}", 1, manager.Tasks.Count()));
Assert.IsTrue(manager.ParentOf(first) == null);
// create second task, remove first task
var second = new Task();
second.Name = "Apple Jack";
manager.Add(second);
manager.Delete(first);
var firstordefault = manager.Tasks.FirstOrDefault();
Assert.IsTrue(firstordefault != null);
Assert.IsTrue(firstordefault.Name == "Apple Jack");
Assert.IsTrue(firstordefault.Equals(second));
// remove a task that is already removed
manager.Delete(first);
Assert.IsTrue(manager.Tasks.Count() == 1);
// remove a null task
manager.Delete(null);
Assert.IsTrue(manager.Tasks.Count() == 1);
}
示例9: CreateAndRemoveGroup
public void CreateAndRemoveGroup()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
var group1 = new Task();
var one = new Task();
var two = new Task();
manager.Add(group1);
manager.Add(one);
manager.Add(two);
// make group
manager.Group(group1, one);
manager.Group(group1, two);
Assert.IsTrue(manager.Tasks.Count() == 3);
Assert.IsTrue(manager.ChildrenOf(group1).Count() == 2);
Assert.IsTrue(manager.ParentOf(one).Equals(group1));
Assert.IsTrue(manager.ParentOf(two).Equals(group1));
// delete group task
manager.Delete(group1);
Assert.IsTrue(manager.Tasks.Count() == 2);
Assert.IsTrue(manager.ChildrenOf(group1).Count() == 0);
Assert.IsTrue(manager.ParentOf(one) == null);
Assert.IsTrue(manager.ParentOf(two) == null);
}
示例10: MoveGroupsAround
public void MoveGroupsAround()
{
IProjectManager<Task, object> manager = new ProjectManager<Task, object>();
// groups
var group1 = new Task() { Name = "group1" };
var group2 = new Task() { Name = "group2" };
var group3 = new Task() { Name = "group3" };
// group 1 tasks
var g1t1 = new Task() { Name = "g1t1" };
var g1t2 = new Task() { Name = "g1t2" };
var g1t3 = new Task() { Name = "g1t3" };
// group 2 tasks
var g2t1 = new Task() { Name = "g2t1" };
var g2t2 = new Task() { Name = "g2t2" };
var g2t3 = new Task() { Name = "g2t3" };
// group 3 tasks
var g3t1 = new Task() { Name = "g3t1" };
var g3t2 = new Task() { Name = "g3t2" };
var g3t3 = new Task() { Name = "g3t3" };
manager.Add(group1);
manager.Add(group2);
manager.Add(group3);
manager.Add(g1t1);
manager.Add(g1t2);
manager.Add(g1t3);
manager.Add(g2t1);
manager.Add(g2t2);
manager.Add(g2t3);
manager.Add(g3t1);
manager.Add(g3t2);
manager.Add(g3t3);
// make groups
manager.Group(group1, g1t1);
manager.Group(group1, g1t2);
manager.Group(group1, g1t3);
// make groups
manager.Group(group2, g2t1);
manager.Group(group2, g2t2);
manager.Group(group2, g2t3);
// make groups
manager.Group(group3, g3t1);
manager.Group(group3, g3t2);
manager.Group(group3, g3t3);
// confirm parents
Assert.IsTrue(manager.ParentOf(group1) == null);
Assert.IsTrue(manager.ParentOf(group2) == null);
Assert.IsTrue(manager.ParentOf(group3) == null);
Assert.IsTrue(manager.ParentOf(g1t1) == group1);
Assert.IsTrue(manager.ParentOf(g1t2) == group1);
Assert.IsTrue(manager.ParentOf(g1t3) == group1);
Assert.IsTrue(manager.ParentOf(g2t1) == group2);
Assert.IsTrue(manager.ParentOf(g2t2) == group2);
Assert.IsTrue(manager.ParentOf(g2t3) == group2);
Assert.IsTrue(manager.ParentOf(g3t1) == group3);
Assert.IsTrue(manager.ParentOf(g3t2) == group3);
Assert.IsTrue(manager.ParentOf(g3t3) == group3);
// confirm order
Assert.IsTrue(manager.IndexOf(group1) == 0);
Assert.IsTrue(manager.IndexOf(g1t1) == 1);
Assert.IsTrue(manager.IndexOf(g1t2) == 2);
Assert.IsTrue(manager.IndexOf(g1t3) == 3);
Assert.IsTrue(manager.IndexOf(group2) == 4);
Assert.IsTrue(manager.IndexOf(g2t1) == 5);
Assert.IsTrue(manager.IndexOf(g2t2) == 6);
Assert.IsTrue(manager.IndexOf(g2t3) == 7);
Assert.IsTrue(manager.IndexOf(group3) == 8);
Assert.IsTrue(manager.IndexOf(g3t1) == 9);
Assert.IsTrue(manager.IndexOf(g3t2) == 10);
Assert.IsTrue(manager.IndexOf(g3t3) == 11);
// move group under itself 1 (not allowed)
manager.Move(group1, 1);
Assert.IsTrue(manager.IndexOf(group1) == 0, string.Format("{0} != {1}", 0, manager.IndexOf(group1)));
Assert.IsTrue(manager.IndexOf(g1t1) == 1);
Assert.IsTrue(manager.IndexOf(g1t2) == 2);
Assert.IsTrue(manager.IndexOf(g1t3) == 3);
Assert.IsTrue(manager.IndexOf(group2) == 4);
Assert.IsTrue(manager.IndexOf(g2t1) == 5);
Assert.IsTrue(manager.IndexOf(g2t2) == 6);
Assert.IsTrue(manager.IndexOf(g2t3) == 7);
Assert.IsTrue(manager.IndexOf(group3) == 8);
Assert.IsTrue(manager.IndexOf(g3t1) == 9);
Assert.IsTrue(manager.IndexOf(g3t2) == 10);
Assert.IsTrue(manager.IndexOf(g3t3) == 11);
// move group under itself 2 (not allowed)
manager.Move(group1, 2);
Assert.IsTrue(manager.IndexOf(group1) == 0);
Assert.IsTrue(manager.IndexOf(g1t1) == 1);
Assert.IsTrue(manager.IndexOf(g1t2) == 2);
Assert.IsTrue(manager.IndexOf(g1t3) == 3);
Assert.IsTrue(manager.IndexOf(group2) == 4);
Assert.IsTrue(manager.IndexOf(g2t1) == 5);
Assert.IsTrue(manager.IndexOf(g2t2) == 6);
Assert.IsTrue(manager.IndexOf(g2t3) == 7);
Assert.IsTrue(manager.IndexOf(group3) == 8);
//.........这里部分代码省略.........