Using multiple copies of the same class

By specifying a quantity in the Component Information dialog in Workbench, or by using the gencs -i option, you can create multiple copies of a single class from the method definitions in the SMC. The purpose of this feature is to enable you to have identical objects that can access different xfServerPlus servers using settings in an application configuration file. This feature can be used either with or without pooling, though it is probably most useful in conjunction with pooling.

For example, you might want to use a single website for several customers. Each customer’s users need to be able to log in on the common webpage, but then access separate sets of data. If you run xfServerPlus on a separate port for each customer, you can use duplicate objects to direct users from customer A to port 2356, users from customer B to port 2357, and so on. Users would be directed to the correct port at log-in, and your application code would be the same for each customer.

The duplicate classes are named with the interface name (or alternate name, if specified), with a number appended to the end. For example, if the interface is named AppLogin, and you specify that you want to create a total of three classes, they will be named AppLogin, AppLogin1, and AppLogin2. The C# interface that is generated for each class (and included in the assembly) enables you to easily access the methods in the duplicated classes.

To create an application that uses multiple copies of the same class, you’ll need to do the following in addition to the steps you’d normally perform:

If you create the assembly from the command line, use the gencs -i option to specify the interfaces for which you want to create multiples classes and the number of classes to create. See Generating C# classes with gencs and Examples for more information.