Using enumerations in xfNetLink .NET
Your Synergy assembly includes the following as enumeration types (also referred to as enums):
- repository enumerations passed as parameters
- repository enumerations passed as return values
- repository enumerations referenced as a field in a structure that is passed as a parameter
There will be a .cs file, named with the enumeration name, for each enumeration.
The enumerators (elements) are assigned based on the enumeration members you defined in the repository. The underlying type of each element in the enum is int.
If you assigned numerical values to the members in repository, they are used; else, values are assigned automatically starting with 0 and incrementing by 1. When you create a new instance of an enum, it has a default value of the enumerator that has been assigned 0, if you do not explicitly assign a value. Consequently, when defining your enumeration in the repository, you should specify as the first member the value you would like to be the default.
The following examples use an enumeration named Color, which has members Green, Blue, etc. (Note that the first letter of each member name is capitalized.) In the first example, the enum is passed as a parameter of the EnumTest1() method. In the second example, the enum is a field within the AcmeCustomer structure class.
//Method call example with an enum parameter AcmeCompanyComponent acme = new AcmeCompanyComponent(); acme.Color companyHat = acme.Color.Green; acme.connect(host, port); acme.EnumTest1(ref companyHat); acme.disconnect(); //Enum field within structure example AcmeCompanyComponent acme = new AcmeCompanyComponent(); AcmeCustomer customer = new AcmeCustomer(); //Structure Customer.ColorChoice = acme.Color.Blue; //Enum field of acme.Color acme.connect(host, port); acme.GetCustomer1(ref customer); acme.disconnect();