将Jscript转换为C#为Sparx EA创建外接程序
我用Jscript编写代码,用于扫描EA项目浏览器中的图表,然后创建一个关于现有元素的元素列表。代码可以正常工作。目前,当我试图将代码(Jscript)转换为C#以为企业架构师创建自定义外接程序时,我遇到了一个问题 这是我在Jscript中代码的一部分:将Jscript转换为C#为Sparx EA创建外接程序,c#,enterprise-architect,jscript,C#,Enterprise Architect,Jscript,我用Jscript编写代码,用于扫描EA项目浏览器中的图表,然后创建一个关于现有元素的元素列表。代码可以正常工作。目前,当我试图将代码(Jscript)转换为C#以为企业架构师创建自定义外接程序时,我遇到了一个问题 这是我在Jscript中代码的一部分: var theModel as EA.Package; theModel = Repository.Models.GetAt( 0 ); // Iterate through all views (top level packages) in
var theModel as EA.Package;
theModel = Repository.Models.GetAt( 0 );
// Iterate through all views (top level packages) in the model
var viewEnumerator = new Enumerator( theModel.Packages );
while ( !viewEnumerator.atEnd() )
{
var currentView as EA.Package;
currentView = viewEnumerator.item();
// Add the name of this view to the output window
Session.Output( currentView.Name );
// Iterate through all diagrams in this view
viewEnumerator.moveNext();
}
这是c#中转换的代码:
但是,我有以下问题:
var viewEnumerator = new Enumerator( theModel.Packages );
错误是:
找不到类型或命名空间名称“枚举器”(是否缺少using指令或程序集引用?)
实际上,我不知道如何在C#中创建类似的东西
任何建议您都可以使用
foreach
循环而不是枚举器
EA.Package theModel;
theModel = Repository.Models.GetAt( 0 );
// Iterate through all views (top level packages) in the model
foreach( EA.Package currentView in theModel.Packages )
{
// Add the name of this view to the output window
MessageBox.Show( currentView.Name );
}
确保键入currentView(不要使用var
),因为EA集合不是强类型集合
EA.Package theModel;
theModel = Repository.Models.GetAt( 0 );
// Iterate through all views (top level packages) in the model
foreach( EA.Package currentView in theModel.Packages )
{
// Add the name of this view to the output window
MessageBox.Show( currentView.Name );
}