Contents of the Generated c# File
Top of the File
The Generated file will include a reference to the FSCProLib.dll file, which is the .NET library for Flynet Viewer. The top of the file when defaults are selected for a screedef file named "Insure" would look like:
Note that the namespace will default to the ScreenDef name--this can be overrided in the Generate Form and this would be one item most likely to be changed to fit the design of the client application.
Enumerations
Each defined FieldID, ScreenID and MapID is enumerated in special Int32 enumerations. Using these enumerations in your internal methods enables Intellisense display of the active enumeration list to pick from, rather than having to remember the different field, screen and map names.
The FieldID enumeration can be used as follows:
Field Length: getFieldLength(FieldID index) // returns length of the field
Screen offset inside a map: fieldOffsets((int) MapID, (int) FieldID) // returns -1 if not inside the map
The MapID enumeration can be used as follows:
Map Information: mapInfos[(int) mapID] // returns a mapInfo struct
MapInfo Struct:
public struct MapInfo
{
public int rows, columns, homeRow, homeColumn;
public FieldID[] fields;
public MapInfo(int rows, int columns, int homeRow, int homeColumn, FieldID[] fields)
{
this.rows=rows;
this.columns=columns;
this.homeRow=homeRow;
this.homeColumn=homeColumn;
this.fields=fields;
}
}
Structure Definitions
For each of the Screen Maps defined in the definitions file, a c# structure will be defined. These structures are particularly handy has holding places for whole screen's worth of data (you can "grab" the data from a screen in one method call and hold it in a defined structure object).
Another use for a defined structure is as a parameter in a web services call when a whole screen is to be returned. An "out" parameter that is a structure is far easier to declare and manage in code than a long list of field names.
Here are Structures for Two Screen Maps
Class Definition
The class name is another option on the generation form and is based by default on the name of the screen definitions file. This class is used to construct a simple screen read/write object to which the client code will pass an active HostScreen object in the constructor. By creating an object associated with the screen definitions, this object then provides methods to read and write screens which do not need a HostScreen object passed in every call.
The Class definition will include a HostScreen object as well as
a number of integer properties used as indexes for mapped
field read/writes. These indexes are more efficient than
string-based field names when reading and writing mapped
fields.
Class Static Constructor
The class static constructor will run once for each process, the first time this class is loaded. Inside the static constructor, all of the "binds" to the field names in each map are performed once to ensure that the indexes of the fields within the maps are correct. This ensures accurate indexes even if the screen definition file has new fields since the generation of the file.
Note that when the class file is generated, the indexes are accurate so if process initialization is a concern, the static constructor can be hand-modified to remove or bypass all the dynamic binding to the field names.
The ScreenDefControl object is used to load the definitions file
then binds the string-based names to the integer indexes. Comment
or remove if class file will be regenerated and distributed each
time fields are changed.
Class Constructor
The class standard constructor includes a live (connected) HostScreen object as the single parameter.
The simple class constructor saves the active
HostScreen object for use in each read/write method
Screen Map Read Methods
For each screen map with one or more fields identified with the read attribute a read method is generated. The read method returns the structure that matches the map being read.
The name of a read method depends on the map name. If the map is the "default" map, the read method will be "read" with the name of the screen appended. Otherwise, it will be "read", the name of the screen, an underscore and the name of the map appended.
The Signon Screen has a map named "default" with two fields. The Read method is named
readSignon() and returns the SignonMap structure.
Screen Map Read - Multirow Map
When a screen map has the Multiple Rows checkbox checked, the generated method will include a rowIndex parameter.
The read method including rowIndex parameter for the "rowData" map of the
"AcctTrans" screen
Screen Map Write
When a screen map has one or more fields with the write attribute, a Screen write method will be generated.
Here is the write method for the Signon screen's default field map. Note that individual
fields are passed when writing since not all of a structure may have writable fields.
Also note that the null value can be passed and no change will be performed
while the empty string will clear the screen field.