这几段代码显示直接整个world层次递归查找会内存溢出,如果一个一个 SPECIFICATION查找就没有问题:
private DbElement GetSpcoByBoltSpref()
{
if (this.mBranchMember.BoltRef == null || !this.mBranchMember.BoltRef.IsValid)
{
return null;
}
DbElement spco = GetSpcoByScope(this.mBranchMember.Spec);
if (spco == null || !spco.IsValid)
{
//spco = GetSpcoByScope(MDB.CurrentMDB.GetFirstWorld(DbType.Catalog));
spco = GetSpcoByScope();
}
return spco;
}
private DbElement GetSpcoByScope()
{
DbElement world = MDB.CurrentMDB.GetFirstWorld(DbType.Catalog);
DBElementCollection coll = new DBElementCollection(world, new TypeFilter(DbElementTypeInstance.SPECIFICATION));
foreach (DbElement item in coll)
{
if (item != null && item.IsValid)
{
DbElement find = GetSpcoByScope(item);
if (find != null && find.IsValid)
{
return find;
}
}
}
return null;
}