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 use Workbench, specify the total number of classes you want to generate for each interface in the Component Information dialog. See the instructions for the Qty field for details.
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.
- Set the host name and port number for each copy of the class using the xfNetLink .NET Configuration Utility. See Setting options in the config file .
- When writing your client code, use the C# interface included in the assembly to access the methods in the duplicated classes. There is a code sample that illustrates this in Writing code that uses pooled objects.
- If you are using pooling, when you run RegSvcs.exe, all of the classes will be included as components in the COM+ application that is created. You’ll need to set the pooling properties (pool size, etc.) for each component. See Implementing .NET pooling for more information.