public class Group
{
public int ID;
public bool Earned;
public bool Available;
public List<Group> ChildGroups;
public List<Item> ChildItems;
}
public class Item
{
public int ID;
public bool Earned;
public bool Available;
}
public class Evaluator
{
public List<Group> FindEarned(Group source)
{
//Filter implementation
foreach (Group grp in source.Groups)
{
grp.Items = grp.Items.Where(
x => x.Earned == true).ToList();
if (grp.Groups != null && grp.Groups.Count > 0)
{
grp.Groups = FilterEarned(grp);
}
else
{
}
}
return source.Groups;
}
}
我的 find Earn 方法应该返回任何子组或项目处于赚取状态的组列表。例子:
Group1 - Pending
-Group11 -pending
-Group12 -pending
-Group13 -Pending
-Item11 -Pending
-Item12 -Pending
Group2
-Group21 -pending
--Group211 -pending
---Item2111 - earned
-Group22 -pending
-Group23 -Pending
-Item21 -Pending
-Item22 -Pending
方法应该返回
Group2
-Group21 -pending
--Group211 -pending
---Item2111 - earned