Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将Jscript转换为C#为Sparx EA创建外接程序_C#_Enterprise Architect_Jscript - Fatal编程技术网

将Jscript转换为C#为Sparx EA创建外接程序

将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

我用Jscript编写代码,用于扫描EA项目浏览器中的图表,然后创建一个关于现有元素的元素列表。代码可以正常工作。目前,当我试图将代码(Jscript)转换为C#以为企业架构师创建自定义外接程序时,我遇到了一个问题

这是我在Jscript中代码的一部分:

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 );
}