Your application can create an instance of an ObjectScript class, immediately generate an Object Gateway proxy for it, and use the proxy to work with the ObjectScript instance (see the chapter on “Using .NET Inverse Proxy Objects”).
In this example, the first line calls the %New() method of ObjectScript class Demo.dataStore, creating an instance in InterSystems IRIS. In .NET, the call returns a corresponding proxy object named dataStoreProxy, which is used to call instance methods and get or set properties of the ObjectScript instance:
// use a classmethod call to create an ObjectScript instance and generate a proxy object
IRISObject dataStoreProxy = (IRISObject)iris.ClassMethodObject("Demo.dataStore","%New");
// use the proxy to call instance methods, get and set properties
dataStoreProxy.InvokeVoid("ititialize");
dataStoreProxy.Set("propertyOne","a string property");
String testString = dataStoreProxy.Get("propertyOne");
dataStoreProxy.Invoke("updateLog","PropertyOne value changed to "+testString);
// pass the proxy back to ObjectScript method ReadDataStore()
iris.ClassMethodObject("Demo.useData","ReadDataStore",dataStoreProxy);
The last line of this example passes the dataStoreProxy proxy to an ObjectScript method named ReadDataStore(), which interprets it as a reference to the original ObjectScript instance. From there, the instance could be saved to the database, passed to another ObjectScript application, or even passed back to your .NET application.