InterSystems IRIS Data Platform 2019.2  /  Using the Object Gateway for .NET

Using the Object Gateway for .NET
Creating Static Proxy Classes
Previous section           Next section
InterSystems: The power behind what matters   

This chapter discusses how to generate static proxy objects, which are precompiled and stored in the class library just like any other class. See the previous chapter, Using Dynamic Object Gateways, for information about dynamic proxies, which are created at runtime. The following topics are covered here:
See Using Wrapper Classes with .NET APIs for a description of the preferred method for importing third-party DLLs. See the Mapping Specification chapter for a detailed description of how .NET classes are mapped to InterSystems IRIS™ proxy classes.
The Object Gateway cannot generate proxy classes for .NET generic classes. It similarly cannot import .NET classes with generic subclasses or subinterfaces.
Using the Studio .NET Object Gateway Wizard
The following steps summarize the procedure:
  1. Start a .NET Object Gateway server. The server must be running before the Wizard can be used.
  2. In Studio, select Tools > Add-ins > Add-ins... to display the list of available add-ins.
  3. Select .Net Gateway Wizard from the Add-ins dialog and click OK. The .Net Gateway Wizard Studio template is displayed:
    The .NET Gateway Wizard Studio Template
  4. Fill out the form. The following items can be defined:
  5. The Wizard displays a list of available classes:
    Selecting Classes to Import
    Check the classes that you want to use, then click Finish.
Generating Proxy Classes Programmatically
This section discusses the following methods of the %Net.Remote.Gateway class:
See the %Net.Remote.Gateway InterSystems IRIS class documentation for a complete listing of all Object Gateway methods.
The %Import() method of the Gateway class sets off the following chain of sequential events:
  1. The InterSystems IRIS session sends an import request.
  2. Upon receiving the request, the Object Gateway worker thread introspects the indicated .NET assemblies and classes.
  3. The thread also loads dependent assemblies either from the local directory or from the Global Assembly Cache (GAC).
  4. If it finds any .NET classes that are new or changed, or that have no proxy classes on the InterSystems IRIS side, the Object Gateway worker thread generates new proxy classes for them.
%Import() Method
The %Import() method imports the given class and all its dependencies by creating and compiling all the necessary proxy classes. The %Import() method returns (in the ByRef argument imported) a list of generated InterSystems IRIS proxy classes. For details of how .NET class definitions are mapped to InterSystems IRIS proxy classes, see the “Mapping Specification” chapter in this guide.
%Import() is a onetime, startup operation. It only needs to be called the first time you wish to generate the InterSystems IRIS proxy classes. It is necessary again only if you recompile your .NET code and wish to regenerate the proxies.
Import Arguments
Before you invoke %Import(), prepare the additionalClassPaths and exclusions arguments. That is, for each argument, create a new %ListOfDataTypes object and call its Insert() method to fill the list. The optional additionalClassPaths argument can be used to supply additional path arguments, such as the names of additional assembly DLLs that contain the classes you are importing via the Object Gateway. List elements should correspond to individual additional assembly DLL entries, which require the following format:
" rootdir\...\mydll.dll "
You can try to load an assembly from a directory outside of where DotNetGatewaySS.exe is running, but you might experience a load error for your assembly when you try to use a class in the assembly. InterSystems recommends that you put all local assemblies in the same directory as DotNetGatewaySS.exe. You can also specify assemblies in the GAC by using partial names for them, System.Data, for example.
Import Dependencies and Exclusions
While mapping a .NET class into an InterSystems IRIS proxy class and importing it into InterSystems IRIS, the Object Gateway loops over all class dependencies discovered in the given .NET class, including all classes referenced as properties and in argument lists. In other words, the Object Gateway collects a list of all class dependencies needed for a successful import of the given class, then walks that dependency list and generates all necessary proxy classes.
You can control this process by specifying a list of assembly and class name prefixes to exclude from this process. While this situation would be rare, it does give you some flexibility to control what classes get imported. The Object Gateway automatically excludes a small subset of assemblies such as Microsoft.* assemblies.
%GetAllClasses() Method
This method returns, in the ByRef argument allClasses, a list of all public classes available in the assembly DLL specified by the first argument, jarFileOrDirectoryName.
%ExpressImport() Method
%ExpressImport() is a one-step convenience class method that combines calls to %Connect(), %Import(), and %Disconnect(). It returns a list of generated proxies. It also logs that list, if the silent argument is set to 0. The name argument is a semicolon-delimited list of classes or assembly DLLs.

Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-10-14 06:33:38