使用JScript,我想在特定的包下枚举元素。
我收到#OBJECTID#,这是包的元素的ID。
我用它来获取元素。
但是当我计算元素时,它们总是为0。
我错过了什么步骤?
function devTest()
{
var package = Repository.GetPackageByGuid("{2255D8C8-F1BB-4069-BDAF-8B303D108C62}");
// When testing use the Element associate to the Package, not
// the Package ID itself (Pretty sure that that
// this equivalent to the #OBJECTID# macro).
var packageElementId = package.Element.ElementID; //NOT: package.PackageID;
var packageElement = Repository.GetElementByID(packageElementId);
var elementCollection = packageElement.Elements();
Session.Output("Element Count: " + elementCollection.Count());
//ALWAYS ZERO. Not showing Classes and Attributes that are nested under the Package.
}
感谢您的帮助!
答案 0 :(得分:2)
原来我需要使用GetPackageByGuid方法返回与元素关联的包。似乎Package的Elements集合是正确的使用方法。去图......
//Get back to the package that is related to the Element before you count Elements:
var package = Repository.GetPackageByGuid(packageElement.ElementGUID);
var elementCollection = package.Elements;
Session.Output("Element Count: " + elementCollection.Count());