说到 APL,我是一个完全的新手,我希望你们中的一些优秀的人能够帮助我......
我有一个用 C# 编写并导出到 dll 的类库。然后我在 Dyalog APL (v14.0) 中导入这个类,我能够实例化类库中定义的类型的对象,并且可以根据需要访问字段。但是我发现自己无法遍历任何 List<T> 的项目。
C# 类(没什么可写的,但我把它包括在内以防万一):
namespace Motor_lib.Objects
{
public class Motor
{
public int? Id_motor = null;
public string Reference = null;
public string Message = null;
public DateTime? Date_modif = null;
public int? Id_hydrotorque = null;
public int? Id_spline = null;
public int? Id_pivot = null;
public int? Id_cam_cover = null;
public int? Id_cam_B_sup = null;
public int? Id_status = null;
public int? Id_CalcType = null;
public Status Status = null;
public Calculation_type Calculation_type = null;
public Spline Spline = null;
public List<Relation> Compatible_Valving_covers;
public Valving_cover Valving_cover = null;
//even more fields...
public Motor()
{
}
//Methods...
}
}
回到 APL:
⎕using ← 'Motor_lib.Objects,D:\Motor_lib.dll'
⍝Fetch a motor from db
myMotor ← Motor.Get 5
⍝The following works
myMotor.Reference
⍝produce the following output
Ref of 5
myMotor.Reference ← ⊂'new ref of 5' ⍝Also works
⍝Now if i do
myMotor.Compatible_Valving_covers.Count
⍝Produces 2 which is correct
myMotor.Compatible_Valving_covers[1].Reference ⍝Also works; I can access the
reference...
我的问题是:如何遍历 List 的每个元素并显示它们的字段值?我尝试了以下没有运气:
]display ⌷¨myMotor.Compatible_Valving_covers
┌────────────────────────────────────────────────────────────┐
│ ┌→───────────────────────────────────────────────────────┐ │
│ │ Motor_lib.Objects.Relation Motor_lib.Objects.Relation │ │
│ └#───────────────────────────────────────────────────────┘ │
└∊───────────────────────────────────────────────────────────┘
如何让它向我显示 Relation 字段的值(如 Relation.Id 或 Relation.Reference ...)
抱歉,这个问题很长,如果不清楚。任何帮助表示赞赏。