I need to map COBOL record layouts into C# (or VB) classes. COBOL record layouts may have many definition levels, and I need to be able to cope with the rule that a field name may be repeated, provided that there is a way of distinguishing which field you mean with full qualification. I thought that I could do the same in C# when I found that a class can be nested within another, so I could directly map the COBOL structure with C# classes corresponding to input and output web service messages like this: -
C#:
However I found (and this page confirmed) that I can't refer to IJSPG2.JZEMPLOYEE.EMPNO. To solve the problem I either have to flatten the message layout and deal with name ambiguity by renaming fields, or use separate classes. I'll handle repeating groups (arrays), by keeping them as separate classes and using C# logic to put the data into an in-memory database (as in this tutorial).
Before I go down this path can somebody please confirm for me that there is no way of creating nested classes (or structures, or any other object type) that I can refer to in this way. I'd prefer not to expend a lot of effort and then find out I didn't need to
C#:
C#:
namespace MyJSv.Models
{
public class IJSPG2
{
public string JZ_Function { get; set; }
public int JZ_Employee_Skip { get; set; }
public class JZEmployee
{
public string EMPNO { get; set; }
...
public string JZ_CURRENCY { get; set; }
}
public class ViewState
{
public string CheckSum_Employee { get; set; }
}
}
}
Before I go down this path can somebody please confirm for me that there is no way of creating nested classes (or structures, or any other object type) that I can refer to in this way. I'd prefer not to expend a lot of effort and then find out I didn't need to