Appendix C: Data Type Mapping for xfNetLink .NET

This appendix includes information on data type mapping for parameters, return values, and fields in repository structures passed as parameters.

Parameter and return value type mapping

The table below shows how parameter and return value data types are mapped from Synergy to C# when the classes are generated.

For decimal, implied-decimal, and integer data types, you can choose to coerce the data to a non-default type on the .NET side by selecting the desired data type in the Coerced type field when defining methods in the MDU. (See the Coerced type field.) If you are using attributes, see the description of cType for instructions on specifying non-default type mapping.

When coercing data to a non-default data type, you should take care to select a type that is suitable for the size of the data that will be placed in the parameter or return value. The data type in the “Default C# data type” column will be used when “Default” is specified for the coerced type in the MDU.

xfNetLink .NET Parameter and Return Value Type Mapping

Data type in SMC

Default C# data type

Non-default C# data types available

^VALa

int

N/A

Alpha

string with trailing spaces trimmed

N/A

Binary (handle)b

byte array

N/A

Decimal (d)

length 9 = int

length > 9 = long

byte, short, sbyte, ushort, uint, ulong, Boolean, DateTime, nullable DateTime, decimal, nullable decimal

Enumeration

enumeration

N/A

Handleb

string

N/A

Implied-decimal (d.)

decimal

double, float

Integer

length < 8 = int

length = 8 = long

byte, short, sbyte, ushort, uint, ulong, Boolean

System.String

string

N/A

a. Return value only.

b. Parameter only.

Field type mapping

The table below shows how data types within repository structures are mapped to C# data types when the classes are generated. The structure itself becomes a class; this table shows what the data types for the properties or fields of that class will be.

The first column indicates the value in the Type field of the Field Definition window in Repository. The second column indicates the value in the Class field and, where necessary, the value in the User data field in that same window.

Some data types can be coerced to a non-default type on the .NET side. To use a non-default type, select the desired data type in the Coerced type field of the Field Definition window in Repository. When coercing data to a non-default data type, you should take care to select a type that is suitable for the size of the data that will be placed in the property or field. The data type in the “Default C# data type” column will be used when “Default” is specified for the coerced type in the Repository.

xfNetLink .NET Field Type Mapping

Field data type in Repository

Format

Default C# data type

Non-default C# data types available

Alpha

N/A

string with trailing spaces trimmed

N/A

AutoSeq

N/A

long

N/A

AutoTime

N/A

DateTime

N/A

Binary

N/A

byte array

You can convert binary fields to strings (which was the pre-9.3 behavior) by using the gencs -nb option. See Generating C# classes with gencs.

Boolean

N/A

Boolean

N/A

Date

YYMMDD
YYYYMMDD
YYJJJ
YYYYJJJ

DateTimea

nullable DateTime

YYPP
YYYYPP

string

N/A

Decimal
(no precision)

N/A

length 9 = int

length > 9 = long

byte, short, sbyte, ushort, uint, ulong, Boolean, decimal, nullable decimal

Decimal
(with precision)

N/A

decimal

double, float, nullable decimal

Enum

N/A

enumeration

N/A

Integer

N/A

length < 8 = int

length = 8 = long

byte, short, sbyte, ushort, uint, ulong, Boolean

Struct

N/A

N/A. Becomes a class (treated the same as a group).

N/A

Time

HHMM
HHMMSS

DateTime

nullable DateTime

User

Date with ^CLASS^= YYYYMMDDHHMISS or YYYYMMDDHHMISSUUUUUU in the User data field

DateTimea

nullable DateTime

Date with any other value in the User data field

string with trailing spaces trimmed

N/A

Alpha

Binary

Numeric

a. When a Synergy routine sends a zero DateTime to xfNetLink .NET, a .NET default date of 01/01/0001 is created. Your client application needs to test for this date to know that a zero date was sent. When xfNetLink .NET sends a date of 01/01/0001 to a Synergy routine, a zero date is created.