private int Extend(ObjectList openedList, string childName)
{
int index = openedList.IndexOf(this);
ObjectList ol = (ObjectList)this.GetPropertyValue(childName);
foreach (GeneralObject go in ol)
{
//已经在列表里,不重复增加
if (!openedList.Contains(go))
{
index++;
//子对象的层次为当前对象层次+1
go.Level = this.Level + 1;
openedList.Insert(index, go);
}
//如果子为可以展开,递归展开子,下一个展开的孩子要在展开的子后面添加
if (go.IsOpened)
{
index = go.Extend(openedList, childName);
}
}
return index;
}