CSharp Objects
This section briefly describes the mapping of struct instances to C Sharp classes.
The underlying philosophy is to provide an intuitive mechanism to manipulate the data structures, and provide automated validation features.
For each struct, 1 cs file is generated ({class}.cs) containing two class definitions:
{class} is the main class. {class} extends XMLStructBase which implements the IXMLStruct interface.
{class}ArrayList is a collection of {class} that is used as the data type for glfields. {class}ArrayList extends XMLStructArrayListBase which implements the IXMLStruct interface.
All files must be included in a project that uses {class}. The project must have the Xooof.XmlStruct namespace which provide helper functions to the generated code.
To each field of the struct corresponds a property of {class}.
For vfields, the variant datatype is exposed, so null values can be manipulated. Howver, the underlying datatype is fixed and an automatic coercion is done whenever a property is set (see the table below).
For gfields, the generated class is used as the datatype.
For vlfields, typed collections are used (see the table below).
For glfields, the generated collection class is used as the datatype.
struct datatype |
C# datatype |
C# collection datatype |
---|---|---|
string |
System.String |
Xooof.XmlStruct.StringArrayList (behaves as an array list of String) |
int |
Xooof.XmlStruct.XsInt32 |
Xooof.XmlStruct.Int32ArrayList (behaves as an array list of XsInt32) |
decimal |
Xooof.XmlStruct.XsDecimal |
Xooof.XmlStruct.DecimalArrayList (behaves as a collection of XsDecimal) |
boolean |
Xooof.XmlStruct.XsBoolean |
Xooof.XmlStruct.BooleanArrayList (behaves as a collection of XsBoolean) |
code |
System.String |
Xooof.XmlStruct.StringArrayList (behaves as a collection of String) |
datetime |
Xooof.XmlStruct.XsDateTime |
Xooof.XmlStruct.DateTimeArrayList (behaves as a collection of XsDateTime) |
time |
Xooof.XmlStruct.XsDateTime |
Xooof.XmlStruct.DateTimeArrayList (behaves as a collection of XsDateTime) |
date |
Xooof.XmlStruct.XsDateTime |
Xooof.XmlStruct.DateTimeArrayList (behaves as a collection of XsDateTime) |
binary |
System.Byte |
Xooof.XmlStruct.BinaryArrayList (behaves as a collection of XSBinary) |
Note The python script struct2cs.py is used to produce CSharp source files from struct instances. |